Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / August 2005

Tip: Looking for answers? Try searching our database.

Problem in using Assembly CreateInstance

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
vinoth@gsdindia.com - 22 Aug 2005 11:50 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.