468,251 Members | 1,372 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,251 developers. It's quick & easy.

Dynamically loading an assembly in ASP.NET application

I have created a DLL (class library) in .NET that I need to dynamically load
from my ASP.NET application.

I am trying to use Assembly.Load(...) to load the file, which is in the /bin
directory of the web app but I am getting a failure.

The class library is just a simple DLL with just one method. It's not
strong name, versioned or installed in the GAC. I just want to load it in
(without using LoadFrom() and explictly passing
c:\inetpub\wwwroot\webapp\bin\mylibrary.dll" which is a major hack IMHO).

Is this possible? I have tried using:

Assembly.Load("MyNamespace");
Assembly.Load("MyNamespace.dll");
Assembly.Load("MyNameSpace MyNamespace.dll")

Is there a way to do this without hacking in a hard-coded path?
Nov 19 '05 #1
3 3964
Try calling Assembly.Load("MyLibrary"). The parameter is the assembly name,
not the namespace inside the assembly (especially since the assembly can
contain several namespaces).

-Brock
DevelopMentor
http://staff.develop.com/ballen
I have created a DLL (class library) in .NET that I need to
dynamically load from my ASP.NET application.

I am trying to use Assembly.Load(...) to load the file, which is in
the /bin directory of the web app but I am getting a failure.

The class library is just a simple DLL with just one method. It's not
strong name, versioned or installed in the GAC. I just want to load
it in (without using LoadFrom() and explictly passing
c:\inetpub\wwwroot\webapp\bin\mylibrary.dll" which is a major hack
IMHO).

Is this possible? I have tried using:

Assembly.Load("MyNamespace");
Assembly.Load("MyNamespace.dll");
Assembly.Load("MyNameSpace MyNamespace.dll")
Is there a way to do this without hacking in a hard-coded path?


Nov 19 '05 #2
another common failure is the dll requires another dll not in the bin
folder.

-- bruce (sqlwork.com)

"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:10***********************@msnews.microsoft.co m...
Try calling Assembly.Load("MyLibrary"). The parameter is the assembly
name, not the namespace inside the assembly (especially since the assembly
can contain several namespaces).
-Brock
DevelopMentor
http://staff.develop.com/ballen
I have created a DLL (class library) in .NET that I need to
dynamically load from my ASP.NET application.

I am trying to use Assembly.Load(...) to load the file, which is in
the /bin directory of the web app but I am getting a failure.

The class library is just a simple DLL with just one method. It's not
strong name, versioned or installed in the GAC. I just want to load
it in (without using LoadFrom() and explictly passing
c:\inetpub\wwwroot\webapp\bin\mylibrary.dll" which is a major hack
IMHO).

Is this possible? I have tried using:

Assembly.Load("MyNamespace");
Assembly.Load("MyNamespace.dll");
Assembly.Load("MyNameSpace MyNamespace.dll")
Is there a way to do this without hacking in a hard-coded path?


Nov 19 '05 #3
Thanks, I did mean the assembly name when I referred to using the namespace
(they are the same in my case). I got it to work, but I had to use:

Assembly.Load ("myassembly, Version=0.0.0.0, PublicKeyToken=null,
Culture=neutral")

Thanks for the help!

"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:10***********************@msnews.microsoft.co m...
Try calling Assembly.Load("MyLibrary"). The parameter is the assembly
name, not the namespace inside the assembly (especially since the assembly
can contain several namespaces).
-Brock
DevelopMentor
http://staff.develop.com/ballen
I have created a DLL (class library) in .NET that I need to
dynamically load from my ASP.NET application.

I am trying to use Assembly.Load(...) to load the file, which is in
the /bin directory of the web app but I am getting a failure.

The class library is just a simple DLL with just one method. It's not
strong name, versioned or installed in the GAC. I just want to load
it in (without using LoadFrom() and explictly passing
c:\inetpub\wwwroot\webapp\bin\mylibrary.dll" which is a major hack
IMHO).

Is this possible? I have tried using:

Assembly.Load("MyNamespace");
Assembly.Load("MyNamespace.dll");
Assembly.Load("MyNameSpace MyNamespace.dll")
Is there a way to do this without hacking in a hard-coded path?


Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by markoueis | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.