By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,417 Members | 1,339 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,417 IT Pros & Developers. It's quick & easy.

Dynamically creating an object

P: n/a
Type codeDomProviderType =
Type.GetType("Microsoft.CSharp*.CSharpCodeProvider ", true);
ObjectHandle objHandle = Activator.CreateInstance(null,
"Microsoft.CSharp.CSharpCodePr*ovider");
Both lines of code throw exceptions when executed, neither one is able
to find the type in question. Am I on the right track? Or should I be
trying to create an instance of the provider a different way.
Example above is hard coded with the CSharpProvider for testing only,
eventually it will be read from a configuration file which one I want
to create.

Nov 16 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
For assemblies in GAC you need to provide fully qualified name:

Type type = Type.GetType("Microsoft.CSharp.CSharpCodeProvider, system,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089,
Custom=null", true);

HTH,
Alexander

"ThisBytes5" <Th********@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Type codeDomProviderType =
Type.GetType("Microsoft.CSharp*.CSharpCodeProvider ", true);
ObjectHandle objHandle = Activator.CreateInstance(null,
"Microsoft.CSharp.CSharpCodePr*ovider");
Both lines of code throw exceptions when executed, neither one is able
to find the type in question. Am I on the right track? Or should I be
trying to create an instance of the provider a different way.
Example above is hard coded with the CSharpProvider for testing only,
eventually it will be read from a configuration file which one I want
to create.
Nov 16 '05 #2

P: n/a
Thank you that did the trick.

Nov 16 '05 #3

P: n/a
Now that I look at the below a bit more, I have one more question.

Where does the custom come from? I've looked at the properties for
windows\assembly and have found everything else but the custom.

Alexander Shirshov wrote:
For assemblies in GAC you need to provide fully qualified name:

Type type = Type.GetType("Microsoft.CSharp.CSharpCodeProvider, system, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=null", true);

HTH,
Alexander


Nov 16 '05 #4

P: n/a
No idea. I simply used "gacutil /l system" to get the full name.

HTH,
Alexander

"ThisBytes5" <Th********@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Now that I look at the below a bit more, I have one more question.

Where does the custom come from? I've looked at the properties for
windows\assembly and have found everything else but the custom.

Alexander Shirshov wrote:
For assemblies in GAC you need to provide fully qualified name:

Type type = Type.GetType("Microsoft.CSharp.CSharpCodeProvider,

system,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089,

Custom=null", true);

HTH,
Alexander

Nov 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.