Throwing exception in AppDomain

I have a problem with deserializing an object:

byte[] cardData;

// Serialize
var mySerializer1 = new BinaryFormatter();
using (var ms = new MemoryStream())
{
    mySerializer1.Serialize(ms, new SuperClass());
    cardData = ms.ToArray();
}

// Deserialize
var mySerializer2 = new BinaryFormatter();
using (var ms = new MemoryStream(cardData))
    mySerializer2.Deserialize(ms);   // throws an exception

      

In the same file:

[Serializable]
public class SuperClass
{ }

      

An exception:

    System.Runtime.Serialization.SerializationException: Unable to find assembly "SKM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null".
 System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly()
 System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo assemblyInfo, String name)
 System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)
 System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record)
 System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum)
 System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
 System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
 System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
 System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)
 SKM.InputFiles.InputFileMsr.GetRecords()  c:\Stas\Projects\CardMaster\Current\MACS\Application\BankProcessors\SKM\InputFiles\InputFileMsr.cs: 204

      

SKM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

is the assembly where I run all this code. Why can't the CLR find it?

I tested this code in a separate application and everything works fine. But in my application an exception is being thrown. Could it be because of the AppDomain I'm loading this DLL in? How to fix it?

UPDATE 2 : Add Fusion Logs.

SKM, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null:

    *** Assembly Binder Log Entry  (28.05.2015 @ 17:05:51) ***

The operation failed.
Bind result: hr = 0x80070002.     .

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Stas\Projects\CardMaster\Current\MACS\Application\Application.DataProcessing\bin\Debug\Application.DataProcessing.vshost.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = SKM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/Stas/Projects/CardMaster/Current/MACS/Application/Application.DataProcessing/bin/Debug
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Stas\Projects\CardMaster\Current\MACS\Application\Application.DataProcessing\bin\Debug\Application.DataProcessing.vshost.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: The same bind was seen before, and was failed with hr = 0x80070002.
ERR: Unrecoverable error occurred during pre-download check (hr = 0x80070002).

*** Assembly Binder Log Entry  (28.05.2015 @ 17:05:51) ***

The operation failed.
Bind result: hr = 0x80070002.     .

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Stas\Projects\CardMaster\Current\MACS\Application\Application.DataProcessing\bin\Debug\Application.DataProcessing.vshost.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = SKM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/Stas/Projects/CardMaster/Current/MACS/Application/Application.DataProcessing/bin/Debug
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Stas\Projects\CardMaster\Current\MACS\Application\Application.DataProcessing\bin\Debug\Application.DataProcessing.vshost.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: The same bind was seen before, and was failed with hr = 0x80070002.
ERR: Unrecoverable error occurred during pre-download check (hr = 0x80070002).

      

SKM:

    *** Assembly Binder Log Entry  (28.05.2015 @ 17:05:51) ***

The operation failed.
Bind result: hr = 0x80070002.     .

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Stas\Projects\CardMaster\Current\MACS\Application\Application.DataProcessing\bin\Debug\Application.DataProcessing.vshost.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = SKM
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: SKM | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Stas/Projects/CardMaster/Current/MACS/Application/Application.DataProcessing/bin/Debug
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Stas\Projects\CardMaster\Current\MACS\Application\Application.DataProcessing\bin\Debug\Application.DataProcessing.vshost.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\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:/Stas/Projects/CardMaster/Current/MACS/Application/Application.DataProcessing/bin/Debug/SKM.DLL.
LOG: Attempting download of new URL file:///C:/Stas/Projects/CardMaster/Current/MACS/Application/Application.DataProcessing/bin/Debug/SKM/SKM.DLL.
LOG: Attempting download of new URL file:///C:/Stas/Projects/CardMaster/Current/MACS/Application/Application.DataProcessing/bin/Debug/SKM.EXE.
LOG: Attempting download of new URL file:///C:/Stas/Projects/CardMaster/Current/MACS/Application/Application.DataProcessing/bin/Debug/SKM/SKM.EXE.
LOG: All probing URLs attempted and failed.

*** Assembly Binder Log Entry  (28.05.2015 @ 17:05:51) ***

The operation failed.
Bind result: hr = 0x80070002.     .

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Stas\Projects\CardMaster\Current\MACS\Application\Application.DataProcessing\bin\Debug\Application.DataProcessing.vshost.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = SKM
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: SKM | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Stas/Projects/CardMaster/Current/MACS/Application/Application.DataProcessing/bin/Debug
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Stas\Projects\CardMaster\Current\MACS\Application\Application.DataProcessing\bin\Debug\Application.DataProcessing.vshost.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\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:/Stas/Projects/CardMaster/Current/MACS/Application/Application.DataProcessing/bin/Debug/SKM.DLL.
LOG: Attempting download of new URL file:///C:/Stas/Projects/CardMaster/Current/MACS/Application/Application.DataProcessing/bin/Debug/SKM/SKM.DLL.
LOG: Attempting download of new URL file:///C:/Stas/Projects/CardMaster/Current/MACS/Application/Application.DataProcessing/bin/Debug/SKM.EXE.
LOG: Attempting download of new URL file:///C:/Stas/Projects/CardMaster/Current/MACS/Application/Application.DataProcessing/bin/Debug/SKM/SKM.EXE.
LOG: All probing URLs attempted and failed.

      

0


source to share





All Articles