473,795 Members | 3,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dynamically load DLL exception when calling Activator.Creat eInstance(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.ToStrin g(dr["RuleLocati on"]);
assemblyInstanc e = Assembly.Load( fileName );
typeInstance = assemblyInstanc e.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.IBaseRul e)Activator.Cre ateInstance(typ eInstance,
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 MissingMethodEx ception, 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 1746

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.LoadFi le
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.ToStrin g(dr["RuleLocati on"]);
assemblyInstan ce = Assembly.Load( fileName );
typeInstance = assemblyInstanc e.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.IBaseRul e)Activator.Cre ateInstance(typ eInstance,
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 MissingMethodEx ception, 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
6684
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 --------------------------------------------------------------------------------------------------------------------------------------------- ERROR MESSAG --------------------------------------------------------------------------------------------------------------------------------------------- Could not load...
0
3324
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 computer but when i put this page on the test sever online on which i have very control and can't recompile over there. i keep on getting error could not load type "_default". Code for the page is as follows <!------------------------- HTML PAGE...
0
5323
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 written in C#. I created a small .exe file to test that the library builds propertly from configuration and that it communicates properly. This work great in the System.Windows.Forms. However, when I use the library in a web enviroment things...
2
419
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 'FormsAuth1.WebForm1' Line 1: <%@ Page Codebehind="WebForm1.aspx.vb" Inherits="FormsAuth1.WebForm1"%> The IIS virtual folder "/Default Web Site/FormsAuth1/Protected" is configured as an application. I'm calling the page directly in IE by typing
4
2720
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 source of the files...
1
1836
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 webservice without calling a webmethod brings up the WSDL and such as I would expect, only when I make an actual call does this happen. Any ideas? System.TypeLoadException: Could not load type...
0
3020
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 deploying the application into a third-part host.
5
8290
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 RoleProvider. However this only occurs after deployment. On my local machine it works fine. So I created the most basic role provider project I could think of. It is below: Imports System.Web.Security
1
1289
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, Version=1.0.2.23169, Culture=neutral,PublicKeyToken=6b57b35e5f0dd756 StackTrace: Server stack trace: at System.Runtime.Remoting.Activation.ActivationListener.Activate(IConstructionCallMessage ctorMsg) at...
3
1849
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 Exception object, I can't just send the message. I need to create an Exception object and make the exc.Message field equal to my message and then pass the new object to the function. Is there a way to do this other than forcing a Catch?
0
9672
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
9519
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
10437
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...
0
10214
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10001
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9042
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6780
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();...
1
4113
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 we have to send another system
2
3723
muto222
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.