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 / July 2005

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sorin.ionescu@gmail.com - 30 Jul 2005 21:10 GMT
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.

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.