473,383 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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 4149
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jon Davis | last post by:
I'm trying to access my application files for a plug-in I'm building for a third party application. I have an assembly with several dependency assemblies. The dependency assemblies are in the...
1
by: Benjamin | last post by:
Hi, I'm currently writing a Web Services that interacts with a database. To allow me to use not just one database provider (for example, I could use MS Access, SQL Server or MySQL), the Web...
7
by: Ollie Riches | last post by:
I am trying to dynamically load an assembly that has a reference to 'Interop.WMEncoderLib.dll' which is a PIA to the windows media player DRM components. When I run the code from a console...
3
by: markoueis | last post by:
Our .NET application, let's call it A, needs to load an assembly of another .NET application, let's call it B. Preferably I would like to early bind and early load the B assembly. However, in a...
6
by: Dan Dorey | last post by:
I actually have two questions here, but I'll start by giving an outline of what I'm trying to do. I'm building an app with a simple plugin architecture (all in the same app domain). I have each...
0
by: mkadasi | last post by:
I want to dynamically create instance of class stored in other application. I am writing the following code for this purpose: Here in the AssemblyFunc() I am loading the assembly of TariffClass...
2
by: Smithers | last post by:
Using 3.5, I am stuck in attempting to: 1. Dynamically load an assembly 2. Instantiate a class from that assembly (the client code is in a different namespace than the namespace of the...
2
by: Smithers | last post by:
I have a Windows Forms application that implements a plug-in architecture whereby required assemblies are identified and loaded dynamically. Here are the relevant classes: A = application =...
7
by: chage | last post by:
Hi, I have been searching around to try adding reference assembly to another assembly during runtime, programatically. Is this possible in .Net? The reason for this is because i am having...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.