Reference an assembly in the config file?

J

Julia

Can some one please explain me the following:

"In your plugin config section, use the assembly name like "Class, Assembly,
Culture, Version, PublicKeyToken" so that you can just use
Type.GetType(name) and instantiate it with GetConstructor(null).Invoke(null)
or use the Type from Type.GetType() to do
type.Assembly.CreateInstance(type.FullName)."

This was published by Heath Stewart in a response to an article regarding
an application which load plugins

I want to use the same method lo dynamically load components to my
application
so if I am correctly understand I can add a"reference" to the assembly
inside the config file
and than create an object using Type.GetType() etc..?

Thanks.
 
S

Scott Allen

Hi Julia:

It seems this article outlines a common plugin approach. In the config
file you have the name of an assembly to load, and once you have the
name of the assembly you can use the System.Reflection.Assembly class
to bring it into your application.

Many plugin architectures also include a type name in the config file
to allow you to use Type.GetType, then System.Activator can create an
instance of the type and you can start using the plugin.

You can find many examples and variations of this architecture with a
quick search:

http://www.google.com/search?hl=en&lr=&ie=UTF-8&q=c#+plugin+architecture

HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top