473,473 Members | 2,215 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Dynamically create objects and set properties?


Here's what I'm trying to do:

Have an xml config file like:

<ObjCollection>
<object assembly = "myAssembly.dll,version,neutral,pkt"
typeName="MyObject" title="" description=""/>
</ObjCollection>

I want to be able to read all the objects listed in this config file,
and be able to create objects from them and set their properties from
the attributes.

someit like:

object obj =
Activator.CreateInstance(xmlNode.attributes["assembly"].value,xmlNode.attributes["typeName"].value);

obj.Title = xmlNode.attributes["title"].value;
.....
Is this at all possible?

Cheers

donal

Nov 17 '05 #1
6 5649
im working on doing something similar with an sql server i havent found
a way taht works yet ...

Nov 17 '05 #2
temp = Activator.CreateInstance(o.GetType());
//o.GetType().InvokeMember("", BindingFlags.CreateInstance, null,
null, null);

this is what i tryed so far no luck i always get the same mistake

Cannot widen from target type to primitive type.

Nov 17 '05 #3
Forgot to mention, this is a web app.

Nov 17 '05 #4
I dont think it makes a difference because mine is also for a web app
but in my case its in a component

Nov 17 '05 #5
Thanks Alexandre, hope u have more luck than I.

Nov 17 '05 #6
donal.conlon <do**********@gmail.com> wrote:

Here's what I'm trying to do:

Have an xml config file like:

<ObjCollection>
<object assembly = "myAssembly.dll,version,neutral,pkt"
typeName="MyObject" title="" description=""/>
</ObjCollection>

I want to be able to read all the objects listed in this config file,
and be able to create objects from them and set their properties from
the attributes.


This sounds like the kind of thing we do in Spring in Java - and
there's a .NET version of Spring too:

http://www.springframework.net/

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #7

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

Similar topics

4
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)"; ...
8
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"); }
8
by: cool2005 | last post by:
I tried to dynamically add/clone a <tr> from an existing <tr> to a <table> but the problem is that I need to have a "onclick" event handler in the <tr>. I have tried following A. approach...
1
by: | last post by:
In Actionscript 2.0 there is the concept of dynamically generating and naming objects at runtime. Dynamically named objects can be referenced and manipulated programmatically using array-access...
11
by: Larry | last post by:
is there a way to add a class property an run-time? If so, how? any code samples? *** Sent via Developersdex http://www.developersdex.com ***
18
by: blueapricot416 | last post by:
I am on a team designing the front end of an Intranet application. The backend guys will be using JSP and AJAX-like functionality to make server requests that must dynamically change elements on a...
12
by: vbnewbie | last post by:
I am having problems accessing properties of dynamically generated objects in VB2005. Can someone please help? In a nutshell: My app creates an equal number of checkboxes and labels that share the...
4
by: wisaunders | last post by:
I have several different classes that contain the same four properties. I tell my application property of which class to call in the configuration file. Here are the values from my config file...
29
by: Quarco | last post by:
This one is driving me nuts.... var tbl = document.createElement("table"); var tbody = document.createElement("tbody"); for(var i=0; i<10; i++) { var row =...
0
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,...
0
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...
0
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,...
0
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.