Click here to Skip to main content
13,259,194 members (52,308 online)
Rate this:
Please Sign up or sign in to vote.
Hi Everybody,

I need some help for the following issue.

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

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

How can I acheive this.

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

Solution 1

You simply add a reference to the DLL in your project.[^]
S Mewara 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.

P A S Saravanan
SAKryukov 16-May-11 21:00pm
Understood. Please see my answer -- it contains all you need to know to accomplish exactly that.
Rate this: bad
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.

Rate this: bad
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
SAKryukov 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.
SAKryukov 16-May-11 20:59pm
Please see my answer -- it's comprehensive.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.171114.1 | Last Updated 16 May 2011
Copyright © CodeProject, 1999-2017
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