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.Serialization
Imports System.IO
Imports Microsoft.VisualBasic
Public Class msdn_example
' The XmlRootAttribute 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.
<XmlRootAttribute("PurchaseOrder", _
Namespace:="http://www.cpandl.com", IsNullable:=False)> _
Public Class PurchaseOrder
Public ShipTo As Address
Public OrderDate As String
' The XmlArrayAttribute changes the XML element name
' from the default of "OrderedItems" to "Items".
<XmlArrayAttribute("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).
<XmlAttributeAttribute()> _
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.
<XmlElementAttribute(IsNullable:=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.xml")
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(GetType(PurchaseOrder))
Dim writer As New StreamWriter(filename)
Dim po As New PurchaseOrder
' Create an address to ship and bill to.
Dim billAddress As New Address
billAddress.Name = "Teresa Atkinson"
billAddress.Line1 = "1 Main St."
billAddress.City = "AnyTown"
billAddress.State = "WA"
billAddress.Zip = "00000"
' Set ShipTo and BillTo to the same addressee.
po.ShipTo = billAddress
po.OrderDate = System.DateTime.Now.ToLongDateString()
' 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.Serialize(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(GetType(PurchaseOrder))
</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 UnknownAttribute events.
AddHandler serializer.UnknownNode, AddressOf
serializer_UnknownNode
AddHandler serializer.UnknownAttribute, AddressOf
serializer_UnknownAttribute
' A FileStream is needed to read the XML document.
Dim fs As New FileStream(filename, 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(serializer.Deserialize(fs), PurchaseOrder)
' Read the order date.
Console.WriteLine(("OrderDate: " & po.OrderDate))
' Read the shipping address.
Dim shipTo As Address = po.ShipTo
ReadAddress(shipTo, "Ship To:")
' Read the list of ordered items.
Dim items As OrderedItem() = po.OrderedItems
Console.WriteLine("Items to be shipped:")
Dim oi As OrderedItem
For Each oi In items
Console.WriteLine((ControlChars.Tab & oi.ItemName &
ControlChars.Tab & _
oi.Description & ControlChars.Tab & oi.UnitPrice &
ControlChars.Tab & _
oi.Quantity & ControlChars.Tab & oi.LineTotal))
Next oi
' Read the subtotal, shipping cost, and total cost.
Console.WriteLine((New String(ControlChars.Tab, 5) & _
" Subtotal" & ControlChars.Tab & po.SubTotal))
Console.WriteLine(New String(ControlChars.Tab, 5) & _
" Shipping" & ControlChars.Tab & po.ShipCost)
Console.WriteLine(New String(ControlChars.Tab, 5) & _
" Total" & New String(ControlChars.Tab, 2) & po.TotalCost)
End Sub 'ReadPO
Protected Sub ReadAddress(ByVal a As Address, ByVal label As
String)
' Read the fields of the Address object.
Console.WriteLine(label)
Console.WriteLine(ControlChars.Tab & a.Name)
Console.WriteLine(ControlChars.Tab & a.Line1)
Console.WriteLine(ControlChars.Tab & a.City)
Console.WriteLine(ControlChars.Tab & a.State)
Console.WriteLine(ControlChars.Tab & a.Zip)
Console.WriteLine()
End Sub 'ReadAddress
Protected Sub serializer_UnknownNode(ByVal sender As Object,
ByVal e As XmlNodeEventArgs)
Console.WriteLine(("Unknown Node:" & e.Name &
ControlChars.Tab & e.Text))
End Sub 'serializer_UnknownNode
Protected Sub serializer_UnknownAttribute(ByVal sender As
Object, ByVal e As XmlAttributeEventArgs)
Dim attr As System.Xml.XmlAttribute = e.Attr
Console.WriteLine(("Unknown attribute " & attr.Name & "='"
& attr.Value & "'"))
End Sub 'serializer_UnknownAttribute
End Class 'Test
End Class
</code> 3 2087
"Mark" <ma********@hotmail.com> wrote in message news:7e**************************@posting.google.c om... 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 (XmlSerialization.Compilation) in the <system.diagnostics> 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
"Derek Harmon" <lo*******@msn.com> wrote in message news:<u7**************@TK2MSFTNGP10.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 (XmlSerialization.Compilation) in the <system.diagnostics> 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
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.ArgumentException: 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.PermissionSet(System.S ecurity.Permissions.SecurityAction.LinkDemand, 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.
PLEEESSSSSSSEEEEE 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.Serialization Imports System.IO Imports Microsoft.VisualBasic
Public Class msdn_example ' The XmlRootAttribute 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. <XmlRootAttribute("PurchaseOrder", _ Namespace:="http://www.cpandl.com", IsNullable:=False)> _ Public Class PurchaseOrder
Public ShipTo As Address Public OrderDate As String ' The XmlArrayAttribute changes the XML element name ' from the default of "OrderedItems" to "Items". <XmlArrayAttribute("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). <XmlAttributeAttribute()> _ 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. <XmlElementAttribute(IsNullable:=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.xml") 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(GetType(PurchaseOrder)) Dim writer As New StreamWriter(filename) Dim po As New PurchaseOrder
' Create an address to ship and bill to. Dim billAddress As New Address billAddress.Name = "Teresa Atkinson" billAddress.Line1 = "1 Main St." billAddress.City = "AnyTown" billAddress.State = "WA" billAddress.Zip = "00000" ' Set ShipTo and BillTo to the same addressee. po.ShipTo = billAddress po.OrderDate = System.DateTime.Now.ToLongDateString()
' 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.Serialize(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(GetType(PurchaseOrder)) </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 UnknownAttribute events. AddHandler serializer.UnknownNode, AddressOf serializer_UnknownNode AddHandler serializer.UnknownAttribute, AddressOf serializer_UnknownAttribute
' A FileStream is needed to read the XML document. Dim fs As New FileStream(filename, 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(serializer.Deserialize(fs), PurchaseOrder) ' Read the order date. Console.WriteLine(("OrderDate: " & po.OrderDate))
' Read the shipping address. Dim shipTo As Address = po.ShipTo ReadAddress(shipTo, "Ship To:") ' Read the list of ordered items. Dim items As OrderedItem() = po.OrderedItems Console.WriteLine("Items to be shipped:") Dim oi As OrderedItem For Each oi In items Console.WriteLine((ControlChars.Tab & oi.ItemName & ControlChars.Tab & _ oi.Description & ControlChars.Tab & oi.UnitPrice & ControlChars.Tab & _ oi.Quantity & ControlChars.Tab & oi.LineTotal)) Next oi ' Read the subtotal, shipping cost, and total cost. Console.WriteLine((New String(ControlChars.Tab, 5) & _ " Subtotal" & ControlChars.Tab & po.SubTotal)) Console.WriteLine(New String(ControlChars.Tab, 5) & _ " Shipping" & ControlChars.Tab & po.ShipCost) Console.WriteLine(New String(ControlChars.Tab, 5) & _ " Total" & New String(ControlChars.Tab, 2) & po.TotalCost) End Sub 'ReadPO
Protected Sub ReadAddress(ByVal a As Address, ByVal label As String) ' Read the fields of the Address object. Console.WriteLine(label) Console.WriteLine(ControlChars.Tab & a.Name) Console.WriteLine(ControlChars.Tab & a.Line1) Console.WriteLine(ControlChars.Tab & a.City) Console.WriteLine(ControlChars.Tab & a.State) Console.WriteLine(ControlChars.Tab & a.Zip) Console.WriteLine() End Sub 'ReadAddress
Protected Sub serializer_UnknownNode(ByVal sender As Object, ByVal e As XmlNodeEventArgs) Console.WriteLine(("Unknown Node:" & e.Name & ControlChars.Tab & e.Text)) End Sub 'serializer_UnknownNode
Protected Sub serializer_UnknownAttribute(ByVal sender As Object, ByVal e As XmlAttributeEventArgs) Dim attr As System.Xml.XmlAttribute = e.Attr Console.WriteLine(("Unknown attribute " & attr.Name & "='" & attr.Value & "'")) End Sub 'serializer_UnknownAttribute End Class 'Test
End Class </code> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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"....
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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...
|
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,...
|
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...
|
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...
|
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,...
| |