473,756 Members | 2,977 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamically creating an object

Type codeDomProvider Type =
Type.GetType("M icrosoft.CSharp *.CSharpCodePro vider", true);
ObjectHandle objHandle = Activator.Creat eInstance(null,
"Microsoft.CSha rp.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
4 1635
For assemblies in GAC you need to provide fully qualified name:

Type type = Type.GetType("M icrosoft.CSharp .CSharpCodeProv ider, system,
Version=1.0.500 0.0, Culture=neutral , PublicKeyToken= b77a5c561934e08 9,
Custom=null", true);

HTH,
Alexander

"ThisBytes5 " <Th********@gma il.com> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
Type codeDomProvider Type =
Type.GetType("M icrosoft.CSharp *.CSharpCodePro vider", true);
ObjectHandle objHandle = Activator.Creat eInstance(null,
"Microsoft.CSha rp.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
Thank you that did the trick.

Nov 16 '05 #3
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\assembl y 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("M icrosoft.CSharp .CSharpCodeProv ider, system, Version=1.0.500 0.0, Culture=neutral , PublicKeyToken= b77a5c561934e08 9, Custom=null", true);

HTH,
Alexander


Nov 16 '05 #4
No idea. I simply used "gacutil /l system" to get the full name.

HTH,
Alexander

"ThisBytes5 " <Th********@gma il.com> wrote in message
news:11******** **************@ o13g2000cwo.goo glegroups.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\assembl y 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("M icrosoft.CSharp .CSharpCodeProv ider,

system,
Version=1.0.500 0.0, Culture=neutral , PublicKeyToken= b77a5c561934e08 9,

Custom=null", true);

HTH,
Alexander

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
12579
by: Eric | last post by:
How can I dynamically assign an event to an element? I have tried : (myelement is a text input) document.getElementById('myelement').onKeyUp = "myfnc(param1,param2,param3)"; document.getElementById('myelement') = new Function("myfnc(param1,param2,param3)");
8
4833
by: Falc2199 | last post by:
Hi, Does anyone know how to make this work? var sectionId = 5; repeat_section_sectionId(); function repeat_section_5(){ alert("firing"); }
6
1919
by: Simon Verona | last post by:
I would normally use code such as : Dim Customer as new Customer Dim t as new threading.thread(AddressOf Customer.DisplayCustomer) Customer.CustomerId=MyCustomerId t.start Which would create a new thread to display a customer on the screen for example. However, I have a problem with circular references in my objects which means that I have to load the customer object using reflection ie :
7
6786
by: pmclinn | last post by:
I was wondering if it is possible to dynamically create a structure. Something like this: public sub main sql = "Select Col1, Col2 from Table a" dim al as new arraylist al = LoadOracleData(sql) '____Do amazing things
3
1089
by: Daniel Friend | last post by:
I have an application and use custom user controls as plugins. Is there any way to communicate back and forth from control to app. NOTE: The control is not refrenced in the app, it will act as a plugin and will be dynamically loaded to the app. Example: 1. My application as a public variable 2. The control must receieve the value of the public variable 3. The control will do some math and encryption of the variable
5
2029
by: SalamElias | last post by:
I am creating several chkBoxes dynamically and assigning an event handler in the Page_load as foillows ***************************** Dim chkCatOption As CheckBox = New CheckBox chkCatOption.Text = rowDS.Item("Option_Item_Desc") chkCatOption.ID = rowDS.Item("ID").ToString chkCatOption.Checked = rowDS.Item("HasOption") chkCatOption.AutoPostBack = True AddHandler chkCatOption.CheckedChanged, AddressOf AddOrUpdate
6
1497
by: Bjorn Sagbakken | last post by:
Hello In VS2005: I am adding buttons and textboxes dynamically into a table, that also dynamically expands. So far, so good, actually very nice. But I am having trouble starting the desired subroutine on postback. To me it seems like the button click event looks for a client script instead of going to the aspx codepage and execute the sub there. The same thing happens with textboxes, where I programatically add
6
5459
by: RSH | last post by:
Hi, i have a situation where I need to dynamically create objects in a loop. My question surrounds intantiation naming in such a scenerio. Below is a snippet that is basically hardcoding each object. My problem is that I would like to create the objects dynamically but I can't figure out how to do it How would I go about dynamically creating the required objects so that I could be using anywhere from 2 - 10 etc. ?
10
2581
by: Jess | last post by:
Hello, If I create a temporary object using a dynamically created object's pointer, then when the temporary object is destroyed, will the dynamically created object be destroyed too? My guess is that it's not destroyed, but I'm not sure. I have the following program: #include<iostream>
4
2973
by: mohaaron | last post by:
I can think of a lot of reasons why this might need to be done but as far as I can tell it's not possible. I've been looking for a way to add HtmlTableRows to a table using a button click for a while and it seems it's not possible because the row that gets added with each click won't get recreated after a post back. After all the reading it seems that any dynamically created controls must be created in the Init event to be recreated after...
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10040
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9873
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3806
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.