Ask a Question related to ASP.NET Security, Design and Development.
-
Nancy Sui #1
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.
Nancy Sui Guest
-
Dynamically loading user control into Placeholder gives Object reference not set to an instance of an object
I've created user controls that contain listboxes that are dynamically populated from the database. In the html view of the user control... -
C# exception after calling Java/Axis web service
I am calling a client's Java/Axis web service (I have no control over it's code). I added the WSDL no problem. When I call their method, I get an... -
Web Service Calling a COM object-throws exception.
I'm trying to write a web service that calls a COM object located on the same machine as the web server, and I'm running into a strange problem. ... -
Security Error When calling assembly.CreateInstance
I don't event know where to begin to solve it. I tried everything I could find on the net, with no avail. I ma loading an assembly using http. Here... -
The file failed to load in the Web Form designer ... Unable to cast object of type myServicedComponentClass ...
I have a user control that inherits from a base user control class. I can view and edit the base user control in the designer. However, my child... -
Scott Allen #2
Re: dynamically load DLL exception when calling Activator.CreateInstance(type, object[])
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
[url]http://www.OdeToCode.com/blogs/scott/[/url]
On 29 Nov 2004 14:44:08 -0800, [email]nanirina@gmail.com[/email] (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.Scott Allen Guest



Reply With Quote

