C# AppDomain中的反序列化异常

C# AppDomain中的反序列化异常,c#,serialization,appdomain,C#,Serialization,Appdomain,我对对象的反序列化有问题: byte[] cardData; // Serialize var mySerializer1 = new BinaryFormatter(); using (var ms = new MemoryStream()) { mySerializer1.Serialize(ms, new SuperClass()); cardData = ms.ToArray(); } // Deserialize var mySerializer2 = new Bi

我对对象的反序列化有问题:

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
在同一文件中:

[Serializable]
public class SuperClass
{ }
例外情况:

    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
是我运行所有代码的程序集。为什么CLR找不到它

我在一个单独的应用程序中测试了这段代码,一切正常。但是在我的应用程序中抛出了一个异常。也许这是因为我加载这个dll的AppDomain?如何修复它

更新2:添加融合日志

SKM,版本=1.0.0.0,区域性=中性,PublicKeyToken=空:

    *** 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:


打开fusion日志记录。应该告诉你发生了什么。@我会添加一个屏幕截图。但我不明白它是什么。除非您的程序名为MSBuild.exe(我打赌不是),否则您正在查看日志以查找错误的程序。可能有用。@将添加一个日志。对不起,这是我的语言。我不能改变它。
    *** 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.