Click here to Skip to main content
11,438,226 members (73,824 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Windows VB.NET Controls
Hi Everybody,

I need some help for the following issue.

I have created a windows control in VB.net and saved as dll file.

I need to show this control in a windows form by loading this file.

How can I acheive this.

Thanks
P A S Saravanan.
Posted 16-May-11 2:54am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You simply add a reference to the DLL in your project.

http://msdn.microsoft.com/en-us/library/wkze6zky(v=vs.80).aspx[^]
  Permalink  
Comments
S Mewara at 16-May-11 10:25am
   
Comment from OP:
Thanks for your info.

But I need to do this step without adding any reference.

Meaning I need to add this control dynamically at the run time.

Thanks
P A S Saravanan
SAKryukov at 16-May-11 21:00pm
   
Understood. Please see my answer -- it contains all you need to know to accomplish exactly that.
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

I provided very detailed skeleton of the design required to consume assemblies during run-time.

Please see my past answers:
Create WPF Application that uses Reloadable Plugins...[^],
AppDomain refuses to load an assembly[^].

It may look overly complex, but don't worry: you probably don't need to solve most complex problems related to unloadable plug-ins and hence Application Domain. Ignore all this.

You only need to develop plug-in interface, the system to recognize its implementation class in the loaded library and invocation of the constructor via Reflection.

—SA
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

You can use Reflection to access a DLL during runtime, something like this:

Assembly asm = Assembly.Load("myclasslibrary.dll");
from there you can access the Classes and Methods in that DLL, using methods like asm.GetTypes() or asm.GetType("yourclass"). Here is the MSDN article on Reflection[^].

Good Luck
  Permalink  
Comments
SAKryukov at 16-May-11 20:55pm
   
Wayne, Don't mislead OP. Did you do it yourself? I think you did not -- it won't work! Assembly.Load does not do what you think.
Must be Assembly.LoadFrom. GetType("yourclass") is a really bad method of doing plug-in, as it relies on hard-coded name. The robust way is based on using interface; then no assumptions are done beyond compiled declaration.
--SA
SAKryukov at 16-May-11 20:59pm
   
Please see my answer -- it's comprehensive.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web03 | 2.8.150506.1 | Last Updated 16 May 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100