473,326 Members | 2,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

C# Assemblies question.

C# Assemblies question.

I have a project that writes out objects as an XML document in a specific
manner that my bosses want to use. I call this project XMLObjectIO . this
project is compiled to an DLL and referenced in the main work project.
Writing and reading primitive types goes off with out a hitch but it an
object contains an object that was written out reconstituting the object is
giving me issues.

The object is written out like this

public void WriteObject(string name, IWriteXML obj)
{
this.WriteStartElement(name);
this.WriteAttributeString("Type", obj.GetType().ToString());

obj.WriteXML(this);
this.WriteEndElement();
}

it writes the start element the attribute string that defines its type and
then writes itself then closes the element. (this works fine)

Reading it in is the problems when I pass the name to look for it finds it
quickly and gets the type that was written out.

string objectType = nav.GetAttribute("Type", "");
System.Type objType = System.Type.GetType(objectType);
objGeneric = Activator.CreateInstance(objType);
IReadXML read = (IReadXML) objGeneric;

Is then called to create an instance of the object and it then reads itself
in. however I get a null from Activator.CreateInstance(objType); saying it
is not in the assembly. I am assuming that this is referring to the DLL's
assembly.

I am looking for a way to access the types of one or possible more projects
the are in the solution. Any Ideas?
Nov 15 '05 #1
2 1106

try using something like this:

public void WriteObject(string name, IWriteXML obj)
{
this.WriteStartElement(name);
this.WriteAttributeString("Type",
obj.GetType().AssemblyQualifiedName.ToString());

obj.WriteXML(this);
this.WriteEndElement();
}
"Wesley Varela" <we********@hotmail.com> wrote in message
news:Xn**********************************@129.250. 170.82...
C# Assemblies question.

I have a project that writes out objects as an XML document in a specific
manner that my bosses want to use. I call this project XMLObjectIO . this
project is compiled to an DLL and referenced in the main work project.
Writing and reading primitive types goes off with out a hitch but it an
object contains an object that was written out reconstituting the object is giving me issues.

The object is written out like this

public void WriteObject(string name, IWriteXML obj)
{
this.WriteStartElement(name);
this.WriteAttributeString("Type", obj.GetType().ToString());

obj.WriteXML(this);
this.WriteEndElement();
}

it writes the start element the attribute string that defines its type and
then writes itself then closes the element. (this works fine)

Reading it in is the problems when I pass the name to look for it finds it
quickly and gets the type that was written out.

string objectType = nav.GetAttribute("Type", "");
System.Type objType = System.Type.GetType(objectType);
objGeneric = Activator.CreateInstance(objType);
IReadXML read = (IReadXML) objGeneric;

Is then called to create an instance of the object and it then reads itself in. however I get a null from Activator.CreateInstance(objType); saying it is not in the assembly. I am assuming that this is referring to the DLL's
assembly.

I am looking for a way to access the types of one or possible more projects the are in the solution. Any Ideas?

Nov 15 '05 #2
Thanks, works perfectly
"Ed Courtenay" <my***********@edcourtenay.co.uk> wrote in message news:<#U**************@tk2msftngp13.phx.gbl>...
try using something like this:

public void WriteObject(string name, IWriteXML obj)
{
this.WriteStartElement(name);
this.WriteAttributeString("Type",
obj.GetType().AssemblyQualifiedName.ToString());

obj.WriteXML(this);
this.WriteEndElement();
}
"Wesley Varela" <we********@hotmail.com> wrote in message
news:Xn**********************************@129.250. 170.82...
C# Assemblies question.

I have a project that writes out objects as an XML document in a specific
manner that my bosses want to use. I call this project XMLObjectIO . this
project is compiled to an DLL and referenced in the main work project.
Writing and reading primitive types goes off with out a hitch but it an
object contains an object that was written out reconstituting the object

is
giving me issues.

The object is written out like this

public void WriteObject(string name, IWriteXML obj)
{
this.WriteStartElement(name);
this.WriteAttributeString("Type", obj.GetType().ToString());

obj.WriteXML(this);
this.WriteEndElement();
}

it writes the start element the attribute string that defines its type and
then writes itself then closes the element. (this works fine)

Reading it in is the problems when I pass the name to look for it finds it
quickly and gets the type that was written out.

string objectType = nav.GetAttribute("Type", "");
System.Type objType = System.Type.GetType(objectType);
objGeneric = Activator.CreateInstance(objType);
IReadXML read = (IReadXML) objGeneric;

Is then called to create an instance of the object and it then reads

itself
in. however I get a null from Activator.CreateInstance(objType); saying

it
is not in the assembly. I am assuming that this is referring to the DLL's
assembly.

I am looking for a way to access the types of one or possible more

projects
the are in the solution. Any Ideas?

Nov 15 '05 #3

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

Similar topics

6
by: Tom Dacon | last post by:
If you're not putting assemblies in the GAC, but are referencing shared code with copylocal=true into the projects that use them, is there any value to signing the assemblies? In the environment...
1
by: BillyMac | last post by:
Hello I emply a "plug-in" architecture for a .NET Windows service. At OnStart, the service browses for DLL's in in sub-folders and loads them dyanamically using Assembly.LoadFrom() The...
12
by: Mark Broadbent | last post by:
Hi guys, just going through remoting at the moment and a couple of questions relating to .net in general has surfaced. Firstly I have seen in the designer that for the namespace and many of its...
9
by: Invalidlastname | last post by:
Hi, We developed some assemblies which use EnterpriseServices queued components. In order to use EnterpriseServices, these assemblies need to be installed into GAC. I used the pre-build and...
10
by: Richard Brown | last post by:
I think I might be on track to a misnomer that I keep running into. A lot of the assemblies that I reference are named "System", "System.Drawing", etc. There are dlls, ie, system.dll and...
7
by: Steve | last post by:
Hi all, I'm designing my DAL layer(s) for our suite of applications and I'm designing myself in circles, it's gotten to the point where each idea just mixes me up more :) We have 3 loosely...
3
by: Claudio Pacciarini | last post by:
Hi everyone, I have a question about .NET code sharing and reuse, and also about application design best practices / guidelines. Currently, we have many different .NET projects in source...
4
by: =?Utf-8?B?VzFsZDBuZTc0?= | last post by:
When one architects a new project one of the first steps in the decision is to decide on the layers. (In my opinion anyway) One architecture that I have used before is to go solid OO and create...
2
by: Smithers | last post by:
I have a Windows Forms application that implements a plug-in architecture whereby required assemblies are identified and loaded dynamically. Here are the relevant classes: A = application =...
2
by: Smithers | last post by:
My ASP.NET Web app uses a few 3rd party assemblies. Just wondering when those are loaded into the Web app's AppDomain - and for how long do they stay loaded. Is an assembly loaded the first time...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.