473,473 Members | 1,807 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

dynamically load DLL exception when calling Activator.CreateInstance(type, object[])

I am trying to dynamically load a dll which specifies different rules
for evalution with the following code.
DataRow dr = ds.Tables[0].Rows[0];
string fileName = Convert.ToString(dr["RuleLocation"]);
assemblyInstance = Assembly.Load( fileName );
typeInstance = assemblyInstance.GetType( "MSF.Storefront.Rules." +
dr["RuleName"].ToString() , true, false);
Object[] parameter = new Object[1];
if (seg == null)
parameter[0] = cs;
else
parameter[0] = seg;

rule = (Rules.IBaseRule)Activator.CreateInstance(typeInst ance,
parameter);
return rule;

this code works fine if the rules are existing .cs files in the
current project and it loads it fine. The problem is when the program
is already running and then I add a new rule .dll into the bin folder,
then try to load that rule dynamically. I get an exception.

the exception i get is the MissingMethodException, member cannot be
found. So then i create an empty constructor and pass in only the
typeInstance, i get a CastException. What is wrong? Please help.
Thanks.
Nov 18 '05 #1
1 1718

Nancy:

If I am reading the description of the problem correctly, then it
sounds as if you are trying to create an instance of a type that is in
an assembly that is not loaded. Are you using Assembly.LoadFile
somewhere to bring that assembly into the process?

--
Scott
http://www.OdeToCode.com/blogs/scott/

On 29 Nov 2004 14:44:08 -0800, na******@gmail.com (Nancy Sui) wrote:
I am trying to dynamically load a dll which specifies different rules
for evalution with the following code.
DataRow dr = ds.Tables[0].Rows[0];
string fileName = Convert.ToString(dr["RuleLocation"]);
assemblyInstance = Assembly.Load( fileName );
typeInstance = assemblyInstance.GetType( "MSF.Storefront.Rules." +
dr["RuleName"].ToString() , true, false);
Object[] parameter = new Object[1];
if (seg == null)
parameter[0] = cs;
else
parameter[0] = seg;

rule = (Rules.IBaseRule)Activator.CreateInstance(typeInst ance,
parameter);
return rule;

this code works fine if the rules are existing .cs files in the
current project and it loads it fine. The problem is when the program
is already running and then I add a new rule .dll into the bin folder,
then try to load that rule dynamically. I get an exception.

the exception i get is the MissingMethodException, member cannot be
found. So then i create an empty constructor and pass in only the
typeInstance, i get a CastException. What is wrong? Please help.
Thanks.


Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mrudul Sadanandan | last post by:
H I am trying to create object in the current app domain using CreateInstanceAndUnwrap. It is throwing the exception. Any ide ...
0
by: M | last post by:
Hi There, I am having lot of trouble getting out the ASP.NET "dll hell", i hope i can find the help here. i have coded a simple page using Visual Studio compiled it. keep on getting works on my...
0
by: phillip | last post by:
This is interesting, I have attached my web.config file and the exception I have been logging. I created a library which provide data access to a database and a control system. The library is...
2
by: John G. | last post by:
I am getting the following error when attempting to browse a page, "WebForm1.aspx", in a web forms project sub-folder, "/FormsAuth1/Protected/". Parser Error Message: Could not load type...
4
by: Don Wash | last post by:
Hi All! I'm getting the following Error: No DLLs has been compiled yet and nothing in the \bin directory. So it is not the versioning problem or anything like that. And here are the...
1
by: mrkurt | last post by:
I've built a few webservices locally that work just fine. Deployed them to a server and I get the following exception. This exception happens on even the most basic webmethod call. Hitting the...
0
by: qiang | last post by:
Hi everyone, Could you please take a look at an exception for ASP.NET application? My ASP.NET application is using Infragistics WebChart control. I encounter an exception below when...
5
by: Alias | last post by:
Hi - I'm trying to implement a custom RoleProvider based on the SqlRoleProvider. I keep receiving a an error that it can't load type 'MyRoleTest.MyRoleProvider' when trying to load my...
1
by: spacefugitive | last post by:
I am relatively new to .NET and completely new to remoting. I am getting an error that goes something like this: Connot load type Chimera.Linestatus.Linestatus, Chimera.Linestatus,...
3
by: tshad | last post by:
I am calling a function that requires an Exception which you normally get from a Catch ( Catch(Exception exc)). But I have a message I am trying to pass to this funtion, but since it requires an...
0
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,...
0
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,...
1
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.