Embedded .dll's

  • Thread starter Thread starter maghana
  • Start date Start date
M

maghana

Hi,

I have a .dll the I want to embed into the main (and
only) assembly, and use it from there ... how do I do
that, or is it even possible ? - please reply by eMail if
you reply to this fast ...

TIA
maghana.

NB : I use the BASS library to play .ogg files
(http://www.un4seen.com/).
 
maghana,

I think that there is a third-party product out there that does this,
but I don't know offhand which it is. Generally speaking though, static
linking is not allowed in .NET. You would have to embed all of the code
into the one project and compile it.

Hope this helps.
 
You could take the assembly and add it to your project as an embedded
resource.
Then, create a stream from the resource at runtime.
You can then load the assembly from the resource stream using assembly.Load
A little reflection and you are there.

Oscar
 
Hmmm ... that sounds very interesting, but won't there be
a problem at compile time, if you already need to refer to
it then ? - is it possible to trick it to "pre-load" the
library, so you can use something like "using BASS;" ?
 
Hi,

I have a .dll the I want to embed into the main (and
only) assembly, and use it from there ... how do I do
that, or is it even possible ? - please reply by eMail if
you reply to this fast ...

TIA
maghana.

NB : I use the BASS library to play .ogg files
(http://www.un4seen.com/).


Here is my take. I personally hate writing DLL's in the traditional
fasion, but fortunatelly Microsoft has made it easy. okay here is the
example, it is derived from a book I got from one of my college
classes called "Inside C# 2nd edition"

Note: since you have one DLL already I'll continue on the one you want
to put it in.

just make a new .cs code file. and write a class

using System;
using System.Diagnostics;
using System.Reflections;


class thisclasstest
{
public static class void loadDll()
{
Assembly EmbeddedDll = Assembley.GetAssembly(
typeof( <Your other dll's name no
extention>));
//now you type in the method or function out want to
//call IE from book. NetModuleTestServer.Bar()
// were NetModuleTestServer is the dll and bar
// is the method
}
}

you will have to compile it in the command window to make it a dll
using this command csc /t:library thisclasstest.cs
of course be in the directory of the CS file and the path to csc
you'll have to find, Mine is
C:\windows\microsoft.net\framework\V1.0.3705\
I may be off on a couple of numbers. anyhow, use the similar code in
your main to call the dll with the embedded one in it and it should
work.

I know it's long and drawn out but it should work I make all my DLL's
this way, though I don't usually embed them. well hope it helps for
what it's worth.

Brian
 
Back
Top