473,692 Members | 2,034 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

weird problem with XMLSerializer

I have an application with a bunch of DLLs that are loaded in as plugins. In
one of these I am trying to get XMLSerializatio n to work but with little
success. I then tried some very simple code shown below as a quick and dirty
test. The kicker is that it works perfectly in the EXE and every DLL except
one. In the one I need it to as a matter of fact. The symptoms is that no
exception is thrown unless I am in the Exceptions window (the CTRL+ALT+E
one) and have Break Into Debugger set, at which point I am told there is an
InvalidCastExce ption with no further information detailed. If I disable the
'Break Into Debugger' then no exception is raised at all but the code skips
a line and nothing gets outputted.

Does anybody have any diea what could possibly make this identical code work
in one place but not another?
module Test

Public Function GenerateStringT est() As String

Dim x As New Test
x.Quantity = 1000

Dim xmlOut As XmlSerializer
Dim stream_writer As MemoryStream

Try
xmlOut = New XmlSerializer(G etType(Test))
stream_writer = New MemoryStream
xmlOut.Serializ e(stream_writer , x) '<---- this line
throws an InvalidCastExce ption
stream_writer.C lose()
Dim encoding As New UTF8Encoding
Return encoding.GetStr ing(stream_writ er.ToArray())
Catch ex As Exception
Return ""
End Try

End Function

end module
Public Class Test
Public Quantity As Double
Public Sub New()
End Sub
End Class

Nov 21 '05 #1
1 1206
is the class marked by the serializable attribute?
Look at the definition of the class Test
Thanks
Deepak
"Armond VanHeusen" wrote:
I have an application with a bunch of DLLs that are loaded in as plugins. In
one of these I am trying to get XMLSerializatio n to work but with little
success. I then tried some very simple code shown below as a quick and dirty
test. The kicker is that it works perfectly in the EXE and every DLL except
one. In the one I need it to as a matter of fact. The symptoms is that no
exception is thrown unless I am in the Exceptions window (the CTRL+ALT+E
one) and have Break Into Debugger set, at which point I am told there is an
InvalidCastExce ption with no further information detailed. If I disable the
'Break Into Debugger' then no exception is raised at all but the code skips
a line and nothing gets outputted.

Does anybody have any diea what could possibly make this identical code work
in one place but not another?
module Test

Public Function GenerateStringT est() As String

Dim x As New Test
x.Quantity = 1000

Dim xmlOut As XmlSerializer
Dim stream_writer As MemoryStream

Try
xmlOut = New XmlSerializer(G etType(Test))
stream_writer = New MemoryStream
xmlOut.Serializ e(stream_writer , x) '<---- this line
throws an InvalidCastExce ption
stream_writer.C lose()
Dim encoding As New UTF8Encoding
Return encoding.GetStr ing(stream_writ er.ToArray())
Catch ex As Exception
Return ""
End Try

End Function

end module
Public Class Test
Public Quantity As Double
Public Sub New()
End Sub
End Class

Nov 21 '05 #2

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

Similar topics

1
1404
by: Ot | last post by:
I have two different solutions that use xml serialization to create xml from a given class. The class is defined identically in both solutions. I copied the code for both the class and the code that does the serialization from the first solution to the second. The first solution works just fine. The second solution gets a weird error.
3
2110
by: Mark | last post by:
Hi all, i'm trying to serialize a class. Using the constructor of XmlSerializer i get these (odd?) errors: "File or assembly name goseij9w.dll, or one of its dependencies, was not found". Everytime i run the testprogram it complains about another exotically named dll like et_kn-hl.dll or afeaqisr.dll. Even the example from msdn throws these errors. Anyone knows wuts wrong?
3
4510
by: Loui Mercieca | last post by:
Hi, I have created a class, named FormField , which basically contains two fields, name and value. I have set the tag before the class and the field is set as an XmlAttribute whil the name as XmlText. In my main class, i have created an arraylist which contains a collection of this class FormField. Basically its: public void Add( string sName, string sValue )
1
2187
by: Sacha | last post by:
I'm having trouble serializing some of my classes when using late binding. When I don't use late binding, it works fine. MyClass inherit from an abstract class called AbsMyClass. If I do the following, it works fine: #BEGIN public static void Write( string fileName ){ MyClass myClass = null; XmlSerializer xmlSerializer = null;
2
2740
by: Scott Reynolds | last post by:
I am having a problem exposing a class inherited from the collection base class as a webservice. If I expose the collection on a web page all works well and I am very happy. However when I try and expose this via a web service I get a weird error saying that the dll could not be found. The specific error is: I can't figure it out. I thought it was to do with reflection but I am able to load and view the webservice definition which...
7
5985
by: MrNobody | last post by:
I was a Java developer so I'm used to using property files as a means to keep configuration settings for my apps. I'm wondering what options are there with ..NET? Some settings I want to include are like a root directory for a target program on the user's machine my app uses, which they would be prompted to supply at startup. Normally the registry is used for this but I'd rather not use the registry if possible. Isn't there some kind of...
10
4014
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the application. What should happen, is that the main MDI form should close, taking the child forms with it. There is code to loop through the child forms, remove the controls on each of them, and then close the form, but this code should execute only...
1
2080
by: Thomas S | last post by:
I want to serialize an object via XmlWriter, but when I serialize to that, 3 strange bytes are added to the beginning of the output (0xEF, 0xBB, and 0xBF) all of which are in the ASCII range (ASCII 239, 187, 191) public static void writeLogItem(LogItem ilog, string lfile) { lock (logLock) { using (StreamWriter outfile = new StreamWriter(lfile, true)) {
0
3181
by: Jamie | last post by:
I've implemented 3 classes, all of which make use of the IXmlSerializable interface. Class A has 2 properties that are instances to class B and C. Class A - serialization routine: public void WriteXml(XmlWriter writer) { writer.WriteAttributeString("test1",test1);
0
8603
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...
1
8797
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8800
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
7627
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6459
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4323
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4557
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2972
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
1957
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.