Hi,
I want to create an Instance of Class using Assembly.CreateInstance
method. I have loaded my assmbly
Assembly exeAssmb = Assembly.LoadWithPartialName"CommonStructures");
//Assembly exeAssmb =
Assembly.LoadFrom("C:\\Inetpub\\wwwroot\\Vinoth\\CommonStructures.dll");
Then when i create an Instance of the Assembly it giving Undefined
Value.
string instClass = "ManWrapper";
object inst =exeAssmb.CreateInstance(instClass);
//object inst =Activator.CreateInstance(exeAssmb.FullName,instClass);
This class(ManWrapper) is in CommonStructures and i registered it in
gacutil also.
I tried the Commentd line also. What is the problem? Is anybody knows
solution please let me know.
Thanks,
Vinoth
Oliver Sturm - 22 Aug 2005 13:02 GMT
> I want to create an Instance of Class using Assembly.CreateInstance
> method. I have loaded my assmbly
[quoted text clipped - 14 lines]
> I tried the Commentd line also. What is the problem? Is anybody knows
> solution please let me know.
If I understand you correctly, you are trying to create an instance of
the class ManWrapper, not of the loaded assembly. You don't mention the
error you are getting - do you mean you simply get a null value returned
by the CreateInstance method? You don't see any exception message during
the process?
Taking a guess about the nature of your problem, I'd say that you might
need to give the complete namespace in addition to the ManWrapper class
name. Usually classes are organized in namespaces (although you could
manually rearrange the class files created automatically by VS to
prevent this from happening) and you'll need to give the namespace in
addition to the class name to be able to create an instance of the class.
Oliver Sturm

Signature
omnibus ex nihilo ducendis sufficit unum
Spaces inserted to prevent google email destruction:
MSN oliver @ sturmnet.org Jabber sturm @ amessage.de
ICQ 27142619 http://www.sturmnet.org/blog
Francois Bonin [MVP] - 23 Aug 2005 00:46 GMT
If you did not get any exception making the Assembly.CreateInstance call,
then the class name you specified was not found. Your issue might be with
the name of the class (including namespace).
On the other hand, if an exception was thrown, you might want to check if
there exists a public parameter-less constructor in the class you need.
HTH
Cois
> Hi,
>
[quoted text clipped - 19 lines]
> Thanks,
> Vinoth