PC Review


Reply
Thread Tools Rate Thread

Activator.CreateInstance(typeof(void)) [.NET 2.0]

 
 
sorin.ionescu@gmail.com
Guest
Posts: n/a
 
      30th Jul 2005
In .NET 2.0, Activator.CreateInstance(typeof(void)) does not work
anymore.

System.NotSupportedException : Cannot dynamically create an instance of
System.Void.

In the documentation, only TypeBuilder, TypedReference, ArgIterator,
and RuntimeArgumentHandle types are listed as not supported.

 
Reply With Quote
 
 
 
 
Lloyd Dupont
Guest
Posts: n/a
 
      31st Jul 2005
that is true.

--
There are 10 kinds of people in this world. Those who understand binary and
those who don't.
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> In .NET 2.0, Activator.CreateInstance(typeof(void)) does not work
> anymore.
>
> System.NotSupportedException : Cannot dynamically create an instance of
> System.Void.
>
> In the documentation, only TypeBuilder, TypedReference, ArgIterator,
> and RuntimeArgumentHandle types are listed as not supported.
>



 
Reply With Quote
 
sorin.ionescu@gmail.com
Guest
Posts: n/a
 
      31st Jul 2005
Is it a bug? If not, why isn't it listed as not supported?

 
Reply With Quote
 
Lloyd Dupont
Guest
Posts: n/a
 
      31st Jul 2005
ahum.. I just didn't understand your post.
Now, after some further reading, I don't quite understand it either except
the 1st line which is almost clear.

So, based on the content of the 1st line I would say, maybe it's a typo?

Try
Activator.CreateInstance<Void>()
instead of
Activator.CreateInstance<void>()

(V != v)
because there is a (System.)Void structure, but there is no such thing as a
void instance.

--
There are 10 kinds of people in this world. Those who understand binary and
those who don't.
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Is it a bug? If not, why isn't it listed as not supported?
>



 
Reply With Quote
 
Willy Denoyette [MVP]
Guest
Posts: n/a
 
      31st Jul 2005

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> In .NET 2.0, Activator.CreateInstance(typeof(void)) does not work
> anymore.
>
> System.NotSupportedException : Cannot dynamically create an instance of
> System.Void.
>
> In the documentation, only TypeBuilder, TypedReference, ArgIterator,
> and RuntimeArgumentHandle types are listed as not supported.
>


This is by design and documented, from the Void structure documentation

Remarks
This structure is used in the System.Reflection namespace. This structure
has no members, and you cannot create an instance of this structure.

Willy.




 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with Activator.CreateInstance() =?Utf-8?B?UXVpbWJseQ==?= Microsoft Dot NET Framework 5 17th Jan 2006 09:05 PM
Need help with Activator.CreateInstance() =?Utf-8?B?UXVpbWJseQ==?= Microsoft Dot NET 1 17th Jan 2006 08:52 PM
Difference Between assembly.CreateInstance and System.Activator.CreateInstance John Jenkins Microsoft C# .NET 1 14th Oct 2004 10:00 PM
Difference Between CurrentDomain.CreateInstance and Activator.CreateInstance b0yce Microsoft Dot NET 0 23rd Mar 2004 03:56 PM
Difference Between CurrentDomain.CreateInstance and Activator.CreateInstance b0yce Microsoft C# .NET 0 22nd Mar 2004 04:12 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:12 PM.