Hello,
I get this error when serializing a object. Specificly an bitmap in the
object. This object is obtained from a different dll than the one
serialized, could that be the problem? That seems to be the only
difference...
Any way to fix this?
Thanks,
Schneider
below if the code and error:
Private Shared Sub SerializeObjectToBinaryFile(ByVal fileName As String,
ByVal value As Object)
If fileName Is Nothing Then Throw New ArgumentNullException("fileName")
If value Is Nothing Then Throw New ArgumentNullException("value")
Dim stream As Stream = Nothing
Try
Dim formatter As IFormatter = New BinaryFormatter
formatter.Binder = New RouteSerializationBinder
stream = New FileStream(fileName, FileMode.Create, FileAccess.Write,
FileShare.None)
formatter.Serialize(stream, value)
Catch ie As System.Runtime.InteropServices.ExternalException
Throw ie
Catch
Throw
Finally
If Not stream Is Nothing Then stream.Close()
End Try
End Sub
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Runtime.InteropServices.ExternalException: A generic error occurred
in GDI+.
at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder,
EncoderParameters encoderParams)
at
System.Drawing.Image.System.Runtime.Serialization.ISerializable.GetObjectData(SerializationInfo
si, StreamingContext context)
at
System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object
obj, ISurrogateSelector surrogateSelector, StreamingContext context,
SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter,
ObjectWriter objectWriter)
at
System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo
objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo)
at
System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object
graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
at
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream
serializationStream, Object graph, Header[] headers, Boolean fCheck)
at
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream
serializationStream, Object graph)
at
SchneiderSoft.NavigationService.NavigationService.SerializeObjectToBinaryFile(String
fileName, Object value) in
E:\AAAA-Controls\Products_SS\SchneiderSoft.UIControls\NavigationService\NavigationService.vb:line
338
at
SchneiderSoft.NavigationService.NavigationService.AddNavigationRoute(INavigationRoute
navigationRoute) in
E:\AAAA-Controls\Products_SS\SchneiderSoft.UIControls\NavigationService\NavigationService.vb:line
157
at
SchneiderSoft.NavigationService.FormManagerNavigationService.btnCreateRoute_CommandInitiate(Object
sender, IBaseEventArgs e) in
E:\AAAA-Controls\Products_SS\SchneiderSoft.UIControls\NavigationService\FormManagerNavigationService.vb:line
70
at SchneiderSoft.UIControls.Button.InternalRaiseCommandInitiate() in
E:\AAAA-Controls\Products_SS\SchneiderSoft.UIControls\ObjectControls\Button.vb:line
580
at SchneiderSoft.UIControls.Button.Button_MouseClick(Object sender,
MouseEventArgs e) in
E:\AAAA-Controls\Products_SS\SchneiderSoft.UIControls\ObjectControls\Button.vb:line
468
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase:
file:///C:/WIN64/Microsoft.NET/Framework64/v2.0.50727/mscorlib.dll
----------------------------------------
TestApp
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase:
file:///E:/AAAA-Controls/Products_SS/SchneiderSoft.UIControls/TestApp/bin/Debug/TestApp.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase:
file:///C:/WIN64/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase:
file:///C:/WIN64/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase:
file:///C:/WIN64/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
Microsoft.VisualBasic
Assembly Version: 8.0.0.0
Win32 Version: 8.0.50727.1433 (REDBITS.050727-1400)
CodeBase:
file:///C:/WIN64/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System.Configuration
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase:
file:///C:/WIN64/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase:
file:///C:/WIN64/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
SchneiderSoft.ObjectControls
Assembly Version: 1.0.5.0
Win32 Version: 1.0.5.0
CodeBase:
file:///E:/AAAA-Controls/Products_SS/SchneiderSoft.UIControls/TestApp/bin/Debug/SchneiderSoft.ObjectControls.DLL
----------------------------------------
SchneiderSoft.AbstractInterfaces
Assembly Version: 1.0.5.0
Win32 Version: 1.0.5.0
CodeBase:
file:///E:/AAAA-Controls/Products_SS/SchneiderSoft.UIControls/TestApp/bin/Debug/SchneiderSoft.AbstractInterfaces.DLL
----------------------------------------
SchneiderSoft.StatisticalManager
Assembly Version: 1.0.5.0
Win32 Version: 1.0.0.0
CodeBase:
file:///C:/Documents%20and%20Settings/Administrator.SCHNEIDER-64/Application%20Data/SchneiderSoft.UIControls/SchneiderSoft.StatisticalManager.dll
----------------------------------------
SchneiderSoft.ObjectRenderers
Assembly Version: 1.0.5.0
Win32 Version: 1.0.5.0
CodeBase:
file:///C:/Documents%20and%20Settings/Administrator.SCHNEIDER-64/Application%20Data/SchneiderSoft.UIControls/SchneiderSoft.ObjectRenderers.dll
----------------------------------------
SchneiderSoft.ObjectControls
Assembly Version: 1.0.5.0
Win32 Version: 1.0.5.0
CodeBase:
file:///C:/Documents%20and%20Settings/Administrator.SCHNEIDER-64/Application%20Data/SchneiderSoft.UIControls/SchneiderSoft.ObjectControls.dll
----------------------------------------
System.Design
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase:
file:///C:/WIN64/assembly/GAC_MSIL/System.Design/2.0.0.0__b03f5f7f11d50a3a/System.Design.dll
----------------------------------------
SchneiderSoft.NavigationService
Assembly Version: 1.0.5.0
Win32 Version: 1.0.5.0
CodeBase:
file:///C:/Documents%20and%20Settings/Administrator.SCHNEIDER-64/Application%20Data/SchneiderSoft.UIControls/SchneiderSoft.NavigationService.dll
----------------------------------------
SchneiderSoft.Licensing
Assembly Version: 2.0.0.87
Win32 Version: 1.0.0.0
CodeBase:
file:///C:/Documents%20and%20Settings/Administrator.SCHNEIDER-64/Application%20Data/SchneiderSoft.UIControls/SchneiderSoft.Licensing.dll
----------------------------------------
SchneiderSoft.Holiday
Assembly Version: 2.0.3003.26391
Win32 Version: 2.0.3003.26391
CodeBase:
file:///C:/Documents%20and%20Settings/Administrator.SCHNEIDER-64/Application%20Data/SchneiderSoft.UIControls/SchneiderSoft.Holiday.dll
----------------------------------------
SchneiderSoft.GeographyInfo
Assembly Version: 2.0.0.0
Win32 Version: 2.0.0.0
CodeBase:
file:///C:/Documents%20and%20Settings/Administrator.SCHNEIDER-64/Application%20Data/SchneiderSoft.UIControls/SchneiderSoft.GeographyInfo.dll
----------------------------------------
SchneiderSoft.GatekeeperConfigFile
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase:
file:///C:/Documents%20and%20Settings/Administrator.SCHNEIDER-64/Application%20Data/SchneiderSoft.UIControls/SchneiderSoft.GatekeeperConfigFile.dll
----------------------------------------
SchneiderSoft.AbstractInterfaces
Assembly Version: 1.0.5.0
Win32 Version: 1.0.5.0
CodeBase:
file:///C:/Documents%20and%20Settings/Administrator.SCHNEIDER-64/Application%20Data/SchneiderSoft.UIControls/SchneiderSoft.AbstractInterfaces.dll
----------------------------------------
3ywn_se2
Assembly Version: 1.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase:
file:///C:/WIN64/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
5gl5j5jc
Assembly Version: 1.0.0.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase:
file:///C:/WIN64/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
oh9jluk_
Assembly Version: 1.0.5.0
Win32 Version: 2.0.50727.1433 (REDBITS.050727-1400)
CodeBase:
file:///C:/WIN64/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
SchneiderSoft.StatisticalManager
Assembly Version: 1.0.5.0
Win32 Version: 1.0.0.0
CodeBase:
file:///E:/AAAA-Controls/Products_SS/SchneiderSoft.UIControls/TestApp/bin/Debug/SchneiderSoft.UIControls/SchneiderSoft.StatisticalManager.dll
----------------------------------------
SchneiderSoft.SpellingCheck
Assembly Version: 2.0.2961.27683
Win32 Version: 2.0.0
CodeBase:
file:///E:/AAAA-Controls/Products_SS/SchneiderSoft.UIControls/TestApp/bin/Debug/SchneiderSoft.UIControls/SchneiderSoft.SpellingCheck.dll
----------------------------------------
SchneiderSoft.ObjectRenderers
Assembly Version: 1.0.5.0
Win32 Version: 1.0.5.0
CodeBase:
file:///E:/AAAA-Controls/Products_SS/SchneiderSoft.UIControls/TestApp/bin/Debug/SchneiderSoft.UIControls/SchneiderSoft.ObjectRenderers.dll
----------------------------------------
SchneiderSoft.ObjectControls
Assembly Version: 1.0.5.0
Win32 Version: 1.0.5.0
CodeBase:
file:///E:/AAAA-Controls/Products_SS/SchneiderSoft.UIControls/TestApp/bin/Debug/SchneiderSoft.UIControls/SchneiderSoft.ObjectControls.dll
----------------------------------------
SchneiderSoft.NavigationService
Assembly Version: 1.0.5.0
Win32 Version: 1.0.5.0
CodeBase:
file:///E:/AAAA-Controls/Products_SS/SchneiderSoft.UIControls/TestApp/bin/Debug/SchneiderSoft.UIControls/SchneiderSoft.NavigationService.dll
----------------------------------------
SchneiderSoft.Licensing
Assembly Version: 2.0.0.87
Win32 Version: 1.0.0.0
CodeBase:
file:///E:/AAAA-Controls/Products_SS/SchneiderSoft.UIControls/TestApp/bin/Debug/SchneiderSoft.UIControls/SchneiderSoft.Licensing.dll
----------------------------------------
SchneiderSoft.GeographyInfo
Assembly Version: 2.0.0.0
Win32 Version: 2.0.0.0
CodeBase:
file:///E:/AAAA-Controls/Products_SS/SchneiderSoft.UIControls/TestApp/bin/Debug/SchneiderSoft.UIControls/SchneiderSoft.GeographyInfo.dll
----------------------------------------
SchneiderSoft.GatekeeperConfigFile
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase:
file:///E:/AAAA-Controls/Products_SS/SchneiderSoft.UIControls/TestApp/bin/Debug/SchneiderSoft.UIControls/SchneiderSoft.GatekeeperConfigFile.dll
----------------------------------------
SchneiderSoft.AbstractInterfaces
Assembly Version: 1.0.5.0
Win32 Version: 1.0.5.0
CodeBase:
file:///E:/AAAA-Controls/Products_SS/SchneiderSoft.UIControls/TestApp/bin/Debug/SchneiderSoft.UIControls/SchneiderSoft.AbstractInterfaces.dll
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
mcse3010 - 12 Apr 2008 00:00 GMT
The problem is simply, the original bitmap isn't done with the underlying
stream... the stream must
remain open for the lifetime of the bitmap, otherwise when an action to
transfer, recreate, redraw the bitmap occurs, the stream isn't there for the
data, and the whole thing kind of breaks down... The problem is described
here:
http://support.microsoft.com/kb/814675/en-us
And basically requires you to create a copy of your bitmap in memory that
isn't dependent on the original stream, then you can do whatever you like
with it (including closing and disposing the original bitmap and stream)...
Hope this helps..
Ciao
> Hello,
> I get this error when serializing a object. Specificly an bitmap in the
[quoted text clipped - 292 lines]
>
> <configuration>
schneider - 14 Apr 2008 04:53 GMT
The following method to copy the image seems to work:
Private Shared Function CopyImage(ByVal value As Bitmap) As Bitmap
Dim bm As Bitmap = New Bitmap(value.Width, value.Height,
Imaging.PixelFormat.Format32bppArgb)
Dim g As Graphics = Graphics.FromImage(bm)
g.DrawImage(value, 0, 0, value.Width, value.Height)
g.Dispose()
Return bm
End Function
> The problem is simply, the original bitmap isn't done with the underlying
> stream... the stream must
[quoted text clipped - 314 lines]
>>
>> <configuration>