Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / October 2004

Tip: Looking for answers? Try searching our database.

About Creating Objects Dynamically (Cont')

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tom - 29 Oct 2004 05:00 GMT
Thanks Chris :

However, during run time, it show error message

"File / component cannot find "
during run in
Dim asm As [Assembly] =
AppDomain.CurrentDomain.Load("D:\vb7Project\dynamicCall\prj01\prj01\bin\prj0
1.dll")

or
Dim asm As [Assembly] = AppDomain.CurrentDomain.Load("prj01.dll")

how can fix it

Thanks
On Thu, 28 Oct 2004 14:46:40 +0800, Tom wrote:

> Ok Thank :
>
> However How to do it as dynamic ?
> I mean , the reference only create on runtime , rather than Predefine.

In order to dynamically create an instance of the class, you must load the
assembly.  Then you can call the GetType method to get the type you're
looking for and create and instance.  This code is untested but should give
you some clues.  (Note the square brackets around the word Assembly.  This
is required since Assembly is a keyword in VB)

Imports System.Reflection

'Dynamically load the .dll
Dim assy As String = "NameOfAssembly.dll"
Dim asm As [Assembly] = AppDomain.CurrentDomain.Load(assy)
Dim ty As Type = asm.GetType("TypeName")
Dim obj As Object = Activator.CreateInstance(t)

Hope this helps you.

Signature

Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.

Chris Dunaway - 29 Oct 2004 14:40 GMT
> Thanks Chris :
>
> However, during run time, it show error message

Try something like this:

Imports System.Reflection

Dim asm As [Assembly] = [Assembly].LoadFrom(AssyFileName)
Dim ty As Type = asm.GetType("TypeName")
Dim obj As Object = Activator.CreateInstance(t)

Signature

Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.

Tom - 30 Oct 2004 02:22 GMT
Thanks

I get it

Many Thanks

> > Thanks Chris :
> >
[quoted text clipped - 7 lines]
> Dim ty As Type = asm.GetType("TypeName")
> Dim obj As Object = Activator.CreateInstance(t)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.