Plug-in arhitecture

  • Thread starter Thread starter George
  • Start date Start date
G

George

Hi, I am trying to develop plug-in for my application.

So i am using following code to dynamically load DLL and create instance of the class

Assembly asem = AppDomain.CurrentDomain.Load(@"C:\folder\Template.dll");

clsTemplate tm = (clsTemplate)asem.CreateInstance("clsTemplate");



The first line gives me an error:

"An unhandled exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll

Additional information: File or assembly name C:\folder\Template.dll, or one of its dependencies, was not found."



I double checked the path the file is there, also there is no dependencies (except standard references).

What do i do wrong?

Thanks

George
 
Load does not take a filename, but rather an assembly name. if you want to load an assembly by filename, read the assembly file into a byte array, and pass the byte array to load.

-- bruce (sqlwork.com)


Hi, I am trying to develop plug-in for my application.

So i am using following code to dynamically load DLL and create instance of the class

Assembly asem = AppDomain.CurrentDomain.Load(@"C:\folder\Template.dll");

clsTemplate tm = (clsTemplate)asem.CreateInstance("clsTemplate");



The first line gives me an error:

"An unhandled exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll

Additional information: File or assembly name C:\folder\Template.dll, or one of its dependencies, was not found."



I double checked the path the file is there, also there is no dependencies (except standard references).

What do i do wrong?

Thanks

George
 
You probably got the answer for your question already Bruce's post. But, I
wanted to point you to
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/pluginframework.asp
which shows how to build a plugin framework. Its really cool and sources are
available. You might want to check it out.

--
Girish Bharadwaj
http://msmvps.com/gbvb
Hi, I am trying to develop plug-in for my application.

So i am using following code to dynamically load DLL and create instance of
the class

Assembly asem = AppDomain.CurrentDomain.Load(@"C:\folder\Template.dll");
clsTemplate tm = (clsTemplate)asem.CreateInstance("clsTemplate");

The first line gives me an error:
"An unhandled exception of type 'System.IO.FileNotFoundException' occurred
in mscorlib.dll
Additional information: File or assembly name C:\folder\Template.dll, or one
of its dependencies, was not found."

I double checked the path the file is there, also there is no dependencies
(except standard references).
What do i do wrong?
Thanks
George
 
Thanks, it works.
Is there easier way to get a class instance from DLL (dynamically, the DLL name is known only at runtime).?

Thanks
George.



Load does not take a filename, but rather an assembly name. if you want to load an assembly by filename, read the assembly file into a byte array, and pass the byte array to load.

-- bruce (sqlwork.com)


Hi, I am trying to develop plug-in for my application.

So i am using following code to dynamically load DLL and create instance of the class

Assembly asem = AppDomain.CurrentDomain.Load(@"C:\folder\Template.dll");

clsTemplate tm = (clsTemplate)asem.CreateInstance("clsTemplate");



The first line gives me an error:

"An unhandled exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll

Additional information: File or assembly name C:\folder\Template.dll, or one of its dependencies, was not found."



I double checked the path the file is there, also there is no dependencies (except standard references).

What do i do wrong?

Thanks

George
 
Yea, thanks
I have plenty experience with pluggins in COM (C++, VB) environment.

But started to shift all my development to .NET and stuck with loading DLL into memory.


George.

You probably got the answer for your question already Bruce's post. But, I
wanted to point you to
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/pluginframework.asp
which shows how to build a plugin framework. Its really cool and sources are
available. You might want to check it out.

--
Girish Bharadwaj
http://msmvps.com/gbvb
Hi, I am trying to develop plug-in for my application.

So i am using following code to dynamically load DLL and create instance of
the class

Assembly asem = AppDomain.CurrentDomain.Load(@"C:\folder\Template.dll");
clsTemplate tm = (clsTemplate)asem.CreateInstance("clsTemplate");

The first line gives me an error:
"An unhandled exception of type 'System.IO.FileNotFoundException' occurred
in mscorlib.dll
Additional information: File or assembly name C:\folder\Template.dll, or one
of its dependencies, was not found."

I double checked the path the file is there, also there is no dependencies
(except standard references).
What do i do wrong?
Thanks
George
 
Back
Top