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.
Lloyd Dupont - 31 Jul 2005 06:24 GMT
that is true.

Signature
There are 10 kinds of people in this world. Those who understand binary and
those who don't.
> In .NET 2.0, Activator.CreateInstance(typeof(void)) does not work
> anymore.
[quoted text clipped - 4 lines]
> In the documentation, only TypeBuilder, TypedReference, ArgIterator,
> and RuntimeArgumentHandle types are listed as not supported.
sorin.ionescu@gmail.com - 31 Jul 2005 14:58 GMT
Is it a bug? If not, why isn't it listed as not supported?
Lloyd Dupont - 31 Jul 2005 15:22 GMT
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.

Signature
There are 10 kinds of people in this world. Those who understand binary and
those who don't.
> Is it a bug? If not, why isn't it listed as not supported?
Willy Denoyette [MVP] - 31 Jul 2005 15:35 GMT
> In .NET 2.0, Activator.CreateInstance(typeof(void)) does not work
> anymore.
[quoted text clipped - 4 lines]
> 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.