dll as embeded resource - vb.net

F

feudalac

I want to embed a dll file and be able to reference it.

I have a dll and use another dll to wich i no longer have the source.
Now i would like to use the second dll within the first dll but when tje
whole thing is compiled, i want to have only one file


How can this be done - i need an example. All i found are examples for c#
for dll embeded in an exe... and all i got from that example is a lot of
errors.



Thanks
 
P

Patrick Steele

I want to embed a dll file and be able to reference it.

This is technically possible, but leads to maintenance headaches. I
wouldn't advise it.
I have a dll and use another dll to wich i no longer have the source.
Now i would like to use the second dll within the first dll but when tje
whole thing is compiled, i want to have only one file

You mean only one DLL? You'll have to have at least two files (an EXE
and a DLL).
How can this be done - i need an example. All i found are examples for c#
for dll embeded in an exe... and all i got from that example is a lot of
errors.

Add the DLL to the class library (DLL). Make sure to set it's "Build
Action" to "Embedded Resource". Use reflection to get the assembly into
a byte[] (Make sure you use Assembly.GetExecutingAssembly() and not
Assembly.GetEntryAssembly()).

Load the byte[] into a new Assembly. Create an instance of your class
and use reflection to make your calls. Not very elegant, but definitely
possible.
 
F

feudalac

thanks!
Patrick Steele said:
I want to embed a dll file and be able to reference it.

This is technically possible, but leads to maintenance headaches. I
wouldn't advise it.
I have a dll and use another dll to wich i no longer have the source.
Now i would like to use the second dll within the first dll but when tje
whole thing is compiled, i want to have only one file

You mean only one DLL? You'll have to have at least two files (an EXE
and a DLL).
How can this be done - i need an example. All i found are examples for c#
for dll embeded in an exe... and all i got from that example is a lot of
errors.

Add the DLL to the class library (DLL). Make sure to set it's "Build
Action" to "Embedded Resource". Use reflection to get the assembly into
a byte[] (Make sure you use Assembly.GetExecutingAssembly() and not
Assembly.GetEntryAssembly()).

Load the byte[] into a new Assembly. Create an instance of your class
and use reflection to make your calls. Not very elegant, but definitely
possible.
 

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