Search:
Namespaces
Discussions
.NET v1.1
Feedback
Problem with Assembly.CreateInstance
Messages
Related Types
This message was discovered on
microsoft.public.dotnet.framework
.
Post a new message to this list...
CoffeeMug
When I execute the following code from ASP.NET my application
sporadically hangs inside CreateInstance(). The hangs don't occur every
time but are frequent enough to be considered a serious problem.
Assembly
asm =
Assembly
.GetAssembly(typeof(MyType));
Type t = asm.GetType("MyType2");
object obj = asm.CreateInstance("MyType2");
MyType as well as MyType2 are C# wrappers for native C functions. I
also noticed that methods of these wrappers (that PInvoke native code)
randomly throw
NullReferenceException
and CreateInstance hangs in
subsequent calls to the page. The problem is tricky to debug since I
can't figure out exact circumstances of the crashes. If anyone could
point me to suggestions or ideas, it'd be great.
Thanks.
Reply to this message...
Robert Jordan
CoffeeMug wrote:
[Original message clipped]
you may try this more straightforward code:
object o =
Activator
.CreateInstance(typeof(MyType));
bye
Rob
Reply to this message...
Mattias Sjögren
[Original message clipped]
Anywhere you can do that, you should also be able to just do
object o = new MyType();
Mattias
--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
|
http://www.dotnetinterop.com
Please reply only to the newsgroup.
Reply to this message...
Robert Jordan
Mattias Sjögren wrote:
[Original message clipped]
LOL!
bye
Rob
Reply to this message...
Girish bharadwaj
Make sure that you can instantiate them without the CreateInstance() calls.
i.e. As someone suggested, try new. If that works. then investigate the
CreateInstance().
Beyond that, How were these wrappers written?
"CoffeeMug" <
Click here to reveal e-mail address
> wrote in message
news:chse2b$
Click here to reveal e-mail address
...
[Original message clipped]
Reply to this message...
System.Activator
System.NullReferenceException
System.Reflection.Assembly
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com