473,769 Members | 5,757 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with serializer constructor

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?
I'll post the example code below.

Thanks in advance,

grtz,

Mark

<code>
Imports System
Imports System.Xml
Imports System.Xml.Seri alization
Imports System.IO
Imports Microsoft.Visua lBasic

Public Class msdn_example
' The XmlRootAttribut e allows you to set an alternate name
' (PurchaseOrder) of the XML element, the element namespace; by
' default, the XmlSerializer uses the class name. The attribute
' also allows you to set the XML namespace for the element.
Lastly,
' the attribute sets the IsNullable property, which specifies
whether
' the xsi:null attribute appears if the class instance is set to
' a null reference.
<XmlRootAttribu te("PurchaseOrd er", _
Namespace:="htt p://www.cpandl.com" , IsNullable:=Fal se)> _
Public Class PurchaseOrder

Public ShipTo As Address
Public OrderDate As String
' The XmlArrayAttribu te changes the XML element name
' from the default of "OrderedIte ms" to "Items".
<XmlArrayAttrib ute("Items")> _
Public OrderedItems() As OrderedItem
Public SubTotal As Decimal
Public ShipCost As Decimal
Public TotalCost As Decimal
End Class 'PurchaseOrder
Public Class Address
' The XmlAttribute instructs the XmlSerializer to serialize
the Name
' field as an XML attribute instead of an XML element (the
default
' behavior).
<XmlAttributeAt tribute()> _
Public Name As String
Public Line1 As String

' Setting the IsNullable property to false instructs the
' XmlSerializer that the XML attribute will not appear if
' the City field is set to a null reference.
<XmlElementAttr ibute(IsNullabl e:=False)> _
Public City As String
Public State As String
Public Zip As String
End Class 'Address
Public Class OrderedItem
Public ItemName As String
Public Description As String
Public UnitPrice As Decimal
Public Quantity As Integer
Public LineTotal As Decimal
' Calculate is a custom method that calculates the price per
item,
' and stores the value in a field.
Public Sub Calculate()
LineTotal = UnitPrice * Quantity
End Sub 'Calculate
End Class 'OrderedItem
Public Class Test

Public Shared Sub Main()
' Read and write purchase orders.
Dim t As New Test
t.CreatePO("po. xml")
t.ReadPO("po.xm l")
End Sub 'Main

Private Sub CreatePO(ByVal filename As String)
' Create an instance of the XmlSerializer class;
' specify the type of object to serialize.
Dim serializer As New
XmlSerializer(G etType(Purchase Order))
Dim writer As New StreamWriter(fi lename)
Dim po As New PurchaseOrder

' Create an address to ship and bill to.
Dim billAddress As New Address
billAddress.Nam e = "Teresa Atkinson"
billAddress.Lin e1 = "1 Main St."
billAddress.Cit y = "AnyTown"
billAddress.Sta te = "WA"
billAddress.Zip = "00000"
' Set ShipTo and BillTo to the same addressee.
po.ShipTo = billAddress
po.OrderDate = System.DateTime .Now.ToLongDate String()

' Create an OrderedItem object.
Dim i1 As New OrderedItem
i1.ItemName = "Widget S"
i1.Description = "Small widget"
i1.UnitPrice = CDec(5.23)
i1.Quantity = 3
i1.Calculate()

' Insert the item into the array.
Dim items(0) As OrderedItem
items(0) = i1
po.OrderedItems = items
' Calculate the total cost.
Dim subTotal As New Decimal
Dim oi As OrderedItem
For Each oi In items
subTotal += oi.LineTotal
Next oi
po.SubTotal = subTotal
po.ShipCost = CDec(12.51)
po.TotalCost = po.SubTotal + po.ShipCost
' Serialize the purchase order, and close the TextWriter.
serializer.Seri alize(writer, po)
writer.Close()
End Sub 'CreatePO

Protected Sub ReadPO(ByVal filename As String)
' Create an instance of the XmlSerializer class;
' specify the type of object to be deserialized.

<HERE IS WHERE IT DOESN'T GO ALL THAT WELL>
Dim serializer As New
XmlSerializer(G etType(Purchase Order))
</HERE IS WHERE IT DOESN'T GO ALL THAT WELL>

' If the XML document has been altered with unknown
' nodes or attributes, handle them with the
' UnknownNode and UnknownAttribut e events.
AddHandler serializer.Unkn ownNode, AddressOf
serializer_Unkn ownNode
AddHandler serializer.Unkn ownAttribute, AddressOf
serializer_Unkn ownAttribute

' A FileStream is needed to read the XML document.
Dim fs As New FileStream(file name, FileMode.Open)
' Declare an object variable of the type to be
deserialized.
Dim po As PurchaseOrder
' Use the Deserialize method to restore the object's state
with
' data from the XML document.
po = CType(serialize r.Deserialize(f s), PurchaseOrder)
' Read the order date.
Console.WriteLi ne(("OrderDate: " & po.OrderDate))

' Read the shipping address.
Dim shipTo As Address = po.ShipTo
ReadAddress(shi pTo, "Ship To:")
' Read the list of ordered items.
Dim items As OrderedItem() = po.OrderedItems
Console.WriteLi ne("Items to be shipped:")
Dim oi As OrderedItem
For Each oi In items
Console.WriteLi ne((ControlChar s.Tab & oi.ItemName &
ControlChars.Ta b & _
oi.Description & ControlChars.Ta b & oi.UnitPrice &
ControlChars.Ta b & _
oi.Quantity & ControlChars.Ta b & oi.LineTotal))
Next oi
' Read the subtotal, shipping cost, and total cost.
Console.WriteLi ne((New String(ControlC hars.Tab, 5) & _
" Subtotal" & ControlChars.Ta b & po.SubTotal))
Console.WriteLi ne(New String(ControlC hars.Tab, 5) & _
" Shipping" & ControlChars.Ta b & po.ShipCost)
Console.WriteLi ne(New String(ControlC hars.Tab, 5) & _
" Total" & New String(ControlC hars.Tab, 2) & po.TotalCost)
End Sub 'ReadPO

Protected Sub ReadAddress(ByV al a As Address, ByVal label As
String)
' Read the fields of the Address object.
Console.WriteLi ne(label)
Console.WriteLi ne(ControlChars .Tab & a.Name)
Console.WriteLi ne(ControlChars .Tab & a.Line1)
Console.WriteLi ne(ControlChars .Tab & a.City)
Console.WriteLi ne(ControlChars .Tab & a.State)
Console.WriteLi ne(ControlChars .Tab & a.Zip)
Console.WriteLi ne()
End Sub 'ReadAddress

Protected Sub serializer_Unkn ownNode(ByVal sender As Object,
ByVal e As XmlNodeEventArg s)
Console.WriteLi ne(("Unknown Node:" & e.Name &
ControlChars.Ta b & e.Text))
End Sub 'serializer_Unk nownNode
Protected Sub serializer_Unkn ownAttribute(By Val sender As
Object, ByVal e As XmlAttributeEve ntArgs)
Dim attr As System.Xml.XmlA ttribute = e.Attr
Console.WriteLi ne(("Unknown attribute " & attr.Name & "='"
& attr.Value & "'"))
End Sub 'serializer_Unk nownAttribute
End Class 'Test

End Class
</code>
Nov 12 '05 #1
3 2114
"Mark" <ma********@hot mail.com> wrote in message news:7e******** *************** ***@posting.goo gle.com...
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.
Christoph Schittko describes how to troubleshoot these kinds of problems in this blog entry,

http://weblogs.asp.net/cschittko/articles/33045.aspx

The strangely named assembly is an assembly that XmlSerializer generates on-the-fly the first
time you construct it. Essentially, to troubleshoot this you can try turning on an undocumented
switch (XmlSerializati on.Compilation) in the <system.diagnos tics> section of your application's
application.exe .config file, and then go into the Temp directory and examine the C# source file
that the Framework dynamically generates for the serializer to see what's wrong.
Even the example from msdn throws these errors.


Make sure the user account under which the application is running has the necessary permissions
to create/write/read the automatically generated assembly in the Temp directory (this is sometimes
a cause for this error with ASP.NET web applications, although it is certainly not the only possible
cause).
Derek Harmon
Nov 12 '05 #2
"Derek Harmon" <lo*******@msn. com> wrote in message news:<u7******* *******@TK2MSFT NGP10.phx.gbl>. ..
<snip>
Christoph Schittko describes how to troubleshoot these kinds of problems in this blog entry,

http://weblogs.asp.net/cschittko/articles/33045.aspx

The strangely named assembly is an assembly that XmlSerializer generates on-the-fly the first
time you construct it. Essentially, to troubleshoot this you can try turning on an undocumented
switch (XmlSerializati on.Compilation) in the <system.diagnos tics> section of your application's
application.exe .config file, and then go into the Temp directory and examine the C# source file
that the Framework dynamically generates for the serializer to see what's wrong. <snip> Derek Harmon


Ty. That helped me debugging the app.

Grtz,

Mark
Nov 12 '05 #3
Hi,
Mark, I have same problem as yours. Did you get solution? Do you know why
did you get that error? I am really desperate...
I am sorry, I dont know why I am unable to create a new question, It asks me
to select news group but the drop down doe not contain any thing!!
Thats why I am putting it here.

I used Chris tool. It really helped me to find the problem. But what about
solution?
I am getting error "System.Argumen tException: Unable to generate permission
set, input xml may be malformed.."

I put the diagnostic switch and found that it is successfully creating
rundime csharp file. But when I use that csharp file and try to compile, then
also I am getting same error.

I really do not understand what this error is. With the user's profile, I
can create a new permission set even at Enterprise, machine level. (using
..net configuration tool.). The user is administartor. There is full
permission to Everyone to Temp directory.

The error is on this lin
[System.Security .Permissions.Pe rmissionSet(Sys tem.Security.Pe rmissions.Secur ityAction.LinkD emand, Name="FullTrust ")]

Looks like it is unable to create permission set. But why? Whats the reason?
This bug is really making me mad. Please help me

Atleast give me a workaround. (I can not serialize all my code by just
writing text like <MyClass></MyClass> etc. because I have heavily used
microsoft's xml serialization code.

PLEEESSSSSSSEEE EE HELP!!

Thanks in advance
Dheeraj

"Mark" wrote:
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?
I'll post the example code below.

Thanks in advance,

grtz,

Mark

<code>
Imports System
Imports System.Xml
Imports System.Xml.Seri alization
Imports System.IO
Imports Microsoft.Visua lBasic

Public Class msdn_example
' The XmlRootAttribut e allows you to set an alternate name
' (PurchaseOrder) of the XML element, the element namespace; by
' default, the XmlSerializer uses the class name. The attribute
' also allows you to set the XML namespace for the element.
Lastly,
' the attribute sets the IsNullable property, which specifies
whether
' the xsi:null attribute appears if the class instance is set to
' a null reference.
<XmlRootAttribu te("PurchaseOrd er", _
Namespace:="htt p://www.cpandl.com" , IsNullable:=Fal se)> _
Public Class PurchaseOrder

Public ShipTo As Address
Public OrderDate As String
' The XmlArrayAttribu te changes the XML element name
' from the default of "OrderedIte ms" to "Items".
<XmlArrayAttrib ute("Items")> _
Public OrderedItems() As OrderedItem
Public SubTotal As Decimal
Public ShipCost As Decimal
Public TotalCost As Decimal
End Class 'PurchaseOrder
Public Class Address
' The XmlAttribute instructs the XmlSerializer to serialize
the Name
' field as an XML attribute instead of an XML element (the
default
' behavior).
<XmlAttributeAt tribute()> _
Public Name As String
Public Line1 As String

' Setting the IsNullable property to false instructs the
' XmlSerializer that the XML attribute will not appear if
' the City field is set to a null reference.
<XmlElementAttr ibute(IsNullabl e:=False)> _
Public City As String
Public State As String
Public Zip As String
End Class 'Address
Public Class OrderedItem
Public ItemName As String
Public Description As String
Public UnitPrice As Decimal
Public Quantity As Integer
Public LineTotal As Decimal
' Calculate is a custom method that calculates the price per
item,
' and stores the value in a field.
Public Sub Calculate()
LineTotal = UnitPrice * Quantity
End Sub 'Calculate
End Class 'OrderedItem
Public Class Test

Public Shared Sub Main()
' Read and write purchase orders.
Dim t As New Test
t.CreatePO("po. xml")
t.ReadPO("po.xm l")
End Sub 'Main

Private Sub CreatePO(ByVal filename As String)
' Create an instance of the XmlSerializer class;
' specify the type of object to serialize.
Dim serializer As New
XmlSerializer(G etType(Purchase Order))
Dim writer As New StreamWriter(fi lename)
Dim po As New PurchaseOrder

' Create an address to ship and bill to.
Dim billAddress As New Address
billAddress.Nam e = "Teresa Atkinson"
billAddress.Lin e1 = "1 Main St."
billAddress.Cit y = "AnyTown"
billAddress.Sta te = "WA"
billAddress.Zip = "00000"
' Set ShipTo and BillTo to the same addressee.
po.ShipTo = billAddress
po.OrderDate = System.DateTime .Now.ToLongDate String()

' Create an OrderedItem object.
Dim i1 As New OrderedItem
i1.ItemName = "Widget S"
i1.Description = "Small widget"
i1.UnitPrice = CDec(5.23)
i1.Quantity = 3
i1.Calculate()

' Insert the item into the array.
Dim items(0) As OrderedItem
items(0) = i1
po.OrderedItems = items
' Calculate the total cost.
Dim subTotal As New Decimal
Dim oi As OrderedItem
For Each oi In items
subTotal += oi.LineTotal
Next oi
po.SubTotal = subTotal
po.ShipCost = CDec(12.51)
po.TotalCost = po.SubTotal + po.ShipCost
' Serialize the purchase order, and close the TextWriter.
serializer.Seri alize(writer, po)
writer.Close()
End Sub 'CreatePO

Protected Sub ReadPO(ByVal filename As String)
' Create an instance of the XmlSerializer class;
' specify the type of object to be deserialized.

<HERE IS WHERE IT DOESN'T GO ALL THAT WELL>
Dim serializer As New
XmlSerializer(G etType(Purchase Order))
</HERE IS WHERE IT DOESN'T GO ALL THAT WELL>

' If the XML document has been altered with unknown
' nodes or attributes, handle them with the
' UnknownNode and UnknownAttribut e events.
AddHandler serializer.Unkn ownNode, AddressOf
serializer_Unkn ownNode
AddHandler serializer.Unkn ownAttribute, AddressOf
serializer_Unkn ownAttribute

' A FileStream is needed to read the XML document.
Dim fs As New FileStream(file name, FileMode.Open)
' Declare an object variable of the type to be
deserialized.
Dim po As PurchaseOrder
' Use the Deserialize method to restore the object's state
with
' data from the XML document.
po = CType(serialize r.Deserialize(f s), PurchaseOrder)
' Read the order date.
Console.WriteLi ne(("OrderDate: " & po.OrderDate))

' Read the shipping address.
Dim shipTo As Address = po.ShipTo
ReadAddress(shi pTo, "Ship To:")
' Read the list of ordered items.
Dim items As OrderedItem() = po.OrderedItems
Console.WriteLi ne("Items to be shipped:")
Dim oi As OrderedItem
For Each oi In items
Console.WriteLi ne((ControlChar s.Tab & oi.ItemName &
ControlChars.Ta b & _
oi.Description & ControlChars.Ta b & oi.UnitPrice &
ControlChars.Ta b & _
oi.Quantity & ControlChars.Ta b & oi.LineTotal))
Next oi
' Read the subtotal, shipping cost, and total cost.
Console.WriteLi ne((New String(ControlC hars.Tab, 5) & _
" Subtotal" & ControlChars.Ta b & po.SubTotal))
Console.WriteLi ne(New String(ControlC hars.Tab, 5) & _
" Shipping" & ControlChars.Ta b & po.ShipCost)
Console.WriteLi ne(New String(ControlC hars.Tab, 5) & _
" Total" & New String(ControlC hars.Tab, 2) & po.TotalCost)
End Sub 'ReadPO

Protected Sub ReadAddress(ByV al a As Address, ByVal label As
String)
' Read the fields of the Address object.
Console.WriteLi ne(label)
Console.WriteLi ne(ControlChars .Tab & a.Name)
Console.WriteLi ne(ControlChars .Tab & a.Line1)
Console.WriteLi ne(ControlChars .Tab & a.City)
Console.WriteLi ne(ControlChars .Tab & a.State)
Console.WriteLi ne(ControlChars .Tab & a.Zip)
Console.WriteLi ne()
End Sub 'ReadAddress

Protected Sub serializer_Unkn ownNode(ByVal sender As Object,
ByVal e As XmlNodeEventArg s)
Console.WriteLi ne(("Unknown Node:" & e.Name &
ControlChars.Ta b & e.Text))
End Sub 'serializer_Unk nownNode
Protected Sub serializer_Unkn ownAttribute(By Val sender As
Object, ByVal e As XmlAttributeEve ntArgs)
Dim attr As System.Xml.XmlA ttribute = e.Attr
Console.WriteLi ne(("Unknown attribute " & attr.Name & "='"
& attr.Value & "'"))
End Sub 'serializer_Unk nownAttribute
End Class 'Test

End Class
</code>

Nov 12 '05 #4

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

Similar topics

2
9931
by: Dale Gerdemann | last post by:
I'm having trouble with Unicode encoding in DOM. As a simple example, I read in a UTF-8 encoded xml file such as: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <aText>letter 'a' with umlaut: ä</aText> And when I serialize it, it comes out encoded as ISO-8895-1. But I don't think the problem is with serialization. In processing my XML files, I'm matching bits and pieces of text and attributes with some
0
1496
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?
1
1497
by: ofer | last post by:
Hi, I am working with the beta version of the new .net framework (Whidbey) and I encountered a problem with serialization that did'nt exist in the .net 2003 the situation is like this : I have a class that inherits from dataset, and I want to serialize it , so I created a serialization constructor that forwards the call to the base class (the dataset) serialization constructor, normally, for this action to succeed I am supposed to put...
2
2357
by: ofer | last post by:
Hi, I am working with the beta version of the new .net framework (Whidbey) and I encountered a problem with serialization that did'nt exist in the .net 2003 the situation is like this : I have a class that inherits from dataset, and I want to serialize it , so I created a serialization constructor that forwards the call to the base class (the dataset) serialization constructor, normally, for this action to succeed I am supposed to put...
6
2191
by: Polo | last post by:
Hi, I have two public enums types each defined in a class (PolarDiagram and KDiagram) in a namespace (RTech.Graphic) I try to serialize this class with XmlSerializer without success A suggestion ? Thank's Polo
4
2965
by: pei_world | last post by:
I have followed a example from a book exactly, but it seems not working at all. can anyone tell me what is going on? ========= Global.asax.cs ============ public static Entry LoadEntry(String filename) { //construct the path
2
4688
by: rakesh kumawat | last post by:
I am facing a problem while reading the result which is loaded in DOMDocument. In which I am sending a request to web service and getting a record of Single Order. This is my VB Code which is i am using.... ......................... Dim Connector As SoapConnector30 ' To connect to webservice Dim Serializer As SoapSerializer30 ' To serialize the XML data Dim Reader As SoapReader30 ' To read the Webservice response...
0
1326
by: rakeshkumawat | last post by:
I am facing a problem while reading the result which is loaded in DOMDocument. In which I am sending a request to web service and getting a record of Single Order. This is my VB Code which is i am using.... ........................ Dim Connector As SoapConnector30 ' To connect to webservice Dim Serializer As SoapSerializer30 ' To serialize the XML data Dim Reader As SoapReader30 ' To read the Webservice...
1
2480
by: sureshbup | last post by:
Hi to all, I am trying to install CPAN modules using the command perl -MCPAN -e 'install qw (Text::CSV_XS)' but i get the problem like this even i changed the working proxies but none is working. i have tried different mirrors also. I tried different modules also. ===========================================================
0
9583
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
9423
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
10210
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
10039
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
9860
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
5297
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...
1
3955
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
2
3560
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2814
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.