473,804 Members | 2,112 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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\wwwr oot\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 4179
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\wwwr oot\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****@NOSPAMd evelop.com> wrote in message
news:10******** *************** @msnews.microso ft.com...
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\wwwr oot\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****@NOSPAMd evelop.com> wrote in message
news:10******** *************** @msnews.microso ft.com...
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\wwwr oot\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
21152
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 same directory as the assembly. d:\dev\cs\MyApp\bin\Release\MyApp.dll d:\dev\cs\MyApp\bin\Release\Dependency1.dll d:\dev\cs\MyApp\bin\Release\Dependency2.dll
1
5022
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 Service dynamically loads up an assembly that implements an Interface I called IDatabase. To load the assembly and create an object, I wrote this function: private IDatabase LoadDatabasePlugin( string assemblyFile, string
7
3045
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 application it works perfectly fine, but when the assembly containing the reference is load from a windows service an exception is thrown with the following message: "File or assembly name Interop.WMEncoderLib, or one of its dependencies, was not...
3
2166
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 deployment scenario, it is possible that B is not installed, in which case, the dependencies for its assembly won't be there. When I try to load that assembly (which is copied) regardless, my application crashes saying that its dependencies cannot...
6
6879
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 plugin in a separate sub-dir inside a "Plugins" directory. Each plugin consists of at least two DLLs (a controller and a driver). However, most drivers also rely on other external DLLs. In one particular case this dependency is to a C++ DLL...
0
1401
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 application which is loaded successfully. In objectCreate() I am creating object of class present in TariffClass application. But I am getting the following error 'Could not load file or assembly 'file:///C:\Inetpub\wwwroot\QuickQuote\TariffClass,...
2
3121
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 dynamically loaded assembly) so far so good (per my code below)... but here is where I'm getting hung up: 3. Call methods of that type (see comments in my code) If the types in the dynamically loaded assembly were in the same namespace
2
5116
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 = Windows Forms class B = a singleton hosted within A. B is responsible for dynamically loading classes X, Y, and Z.
7
10088
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 trouble using a library that creates an instance of a Type that i specified, and it failed the locate the Type during runtime, if i do not reference it during compile time.
0
9712
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10595
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10341
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7634
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.