|
-
Jun 5th, 2010, 10:00 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Serialization
Ok i made an assembly that contains a class DownloadJob
I load the assembly into another project (the download manager) and i am trying to serialize the downloadjob into an xml file as such:
Code:
Public Sub Save()
Dim objStreamWriter As New IO.StreamWriter("C:\Product.xml")
Dim x As New System.Xml.Serialization.XmlSerializer(Me.GetType)
x.Serialize(objStreamWriter, Me)
objStreamWriter.Close()
End Sub
I put the save function in the assembly in the class downloadjob itself so ME refers to the DownloadJob class object that i want to serialize
I get this huge exception:
The assembly with display name 'Download Client.XmlSerializers' failed to load in the 'LoadFrom' binding context of the AppDomain with ID 1. The cause of the failure was: System.IO.FileNotFoundException: Could not load file or assembly 'Download Client.XmlSerializers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'Download Client.XmlSerializers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
=== Pre-bind state information ===
LOG: User = Imad-PC\Imad
LOG: DisplayName = Download Client.XmlSerializers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null, processorArchitecture=x86
(Fully-specified)
LOG: Appbase = file:///C:/Users/Imad/Documents/Visual Studio 2008/Projects/Download Manager/Download Manager/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Users/Imad/Documents/Visual Studio 2008/Projects/Download Manager/Download Manager/bin/Debug/Download Client.XmlSerializers.DLL.
LOG: Attempting download of new URL file:///C:/Users/Imad/Documents/Visual Studio 2008/Projects/Download Manager/Download Manager/bin/Debug/Download Client.XmlSerializers/Download Client.XmlSerializers.DLL.
LOG: Attempting download of new URL file:///C:/Users/Imad/Documents/Visual Studio 2008/Projects/Download Manager/Download Manager/bin/Debug/Download Client.XmlSerializers.EXE.
LOG: Attempting download of new URL file:///C:/Users/Imad/Documents/Visual Studio 2008/Projects/Download Manager/Download Manager/bin/Debug/Download Client.XmlSerializers/Download Client.XmlSerializers.EXE.
however when i turn off exceptions serioalization works and i dont have a problem.
the exception thrown however means there is something im doing wrong or could do better. In lazier times i would have ignored it but now im trying to do things the right way as much as possible.
So, what is this binding error i dont understand the exception at all..and no clue what i have to do.
Basketball-NBA Dream status - quit
Programming-Next Bill Gates Dream status - quit
Becoming a doctor dream - LIVING IT: Med 2\4
-
Jun 5th, 2010, 11:21 PM
#2
Thread Starter
Hyperactive Member
Re: Serialization
how do i create Download Client.XmlSerializers.DLL?
i googled and found so much but nothing relevant and i tried msdn so much xml stuff to do.
But how do i make an XMLSerializers assembly?
Basketball-NBA Dream status - quit
Programming-Next Bill Gates Dream status - quit
Becoming a doctor dream - LIVING IT: Med 2\4
-
Jun 6th, 2010, 01:29 AM
#3
Thread Starter
Hyperactive Member
Re: Serialization
after much googling + some luck i solved this
have to add this to post build events to generate the file:
"C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\sgen.exe" /force /assembly:"$(TargetPath)"
Also must set CPU in compile options to anyPC (doesnt work if x86 or x64 is selected, gives an error that claims its not the same serialization file as the one generated at run time)
Basketball-NBA Dream status - quit
Programming-Next Bill Gates Dream status - quit
Becoming a doctor dream - LIVING IT: Med 2\4
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|