开发者

SerializationException using VS 2008 Addin: not find assemby

开发者 https://www.devze.com 2023-02-08 07:34 出处:网络
I\'m writing a Visual Studio 2008 add-in and all was working fine, but few days, sometimes, there are strange errors about Serialization (unable to find assembly).

I'm writing a Visual Studio 2008 add-in and all was working fine, but few days, sometimes, there are strange errors about Serialization (unable to find assembly).

My addins compile work, and runtime too.

When open new instance Visual Studio, my addin fails when click menu option.

but then if open solution all works (few sometimes fails)

code:

 private void AbrirFicheroMfa()
        {
            using (Stream containerStream = File.OpenRead(this.FicheroMFA))
            {
                mfaContainer = this.Deserialize(containerStream);
                containerStream.Close();
            }
        }

        public MfaContainer Deserialize(Stream serializationStream)
        {
            var formatter = new BinaryFormatter();
            return (MfaContainer)formatter.Deserialize(serial开发者_运维知识库izationStream);
        }

error:

Error al abrir Mfa en VisorMfa: Unable to find assembly 'COMPANY.LifeCycle.Mfa, Version=2.0.0.0, Culture=neutral, PublicKeyToken=9744987c0853bf9e'.

Tipo: System.Runtime.Serialization.SerializationException

Mensaje: Unable to find assembly 'COMPANY.LifeCycle.Mfa, Version=2.0.0.0, Culture=neutral, PublicKeyToken=9744987c0853bf9e'.

StackTrace:

at System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly()

at System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo assemblyInfo, String name)

at 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)

at System.Runtime.Serialization.Formatters.Binary.ObjectMap.Create(String name, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)

at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record)

at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum)

at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()

at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)

at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)

at COMPANY.VSIntegration.ComunDespliegue.Visualizadores.FrmVisorMfaICSharpCode.Deserialize(Stream serializationStream) in E:\TFS\pro\COMPANYTeam\Main\Public\COMPANYDevelopment\COMPANY.VSIntegration.ComunDespliegue\Visualizadores\VisorMfa\FrmVisorMfa.cs:line 139

at COMPANY.VSIntegration.ComunDespliegue.Visualizadores.FrmVisorMfaICSharpCode.AbrirFicheroMfa() in E:\TFS\pro\COMPANYTeam\Main\Public\COMPANYDevelopment\COMPANY.VSIntegration.ComunDespliegue\Visualizadores\VisorMfa\FrmVisorMfa.cs:line 131

at COMPANY.VSIntegration.ComunDespliegue.Visualizadores.FrmVisorMfaICSharpCode.FrmICSharpCode_Load(Object sender, EventArgs e) in E:\TFS\pro\COMPANYTeam\Main\Public\COMPANYDevelopment\COMPANY.VSIntegration.ComunDespliegue\Visualizadores\VisorMfa\FrmVisorMfa.cs:line 72

any suggestions ?

update: once I get this error:

SerializationException:

[A]COMPANY.LifeCycle.Mfa.MfaContainer cannot be cast to [B]COMPANY.LifeCycle.Mfa.MfaContainer.

Type A originates from 'COMPANY.LifeCycle.Mfa, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'LoadFrom' at location 'C:\Projects\Addins\Mfa\COMPANY.LifeCycle.Mfa.dll'.

Type B originates from 'COMPANY.LifeCycle.Mfa, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'LoadNeither' at location 'C:\Documents and Settings\eprados\Configuración local\Datos de programa\Microsoft\VisualStudio\9.0\ProjectAssemblies\wi3h64z601\COMPANY.LifeCycle.Mfa.dll'.

I have an WinForms application and all is work. Serialization is ok.

For VS Addin, I have:

Addin.dll references ComunDespliegue.dll and LifeCycle.Mfa.dll

ComunDespliegue.dll references LifeCycle.Mfa.dll

For WinForms app, I have:

UI.Client.dll references ComunDespliegue.dll and LifeCycle.Mfa.dll

The assembly reside in the addin directory alongside my addin. the type i'm serializing is serializable. The COMPANY.LifeCycle.Mfa.dll is the same.


Use Fuslogvw.exe to find out where the CLR looked for the assembly. There are two basic reasons. First is that you incremented the [AssemblyVersion] of the assembly in a recent update and are trying to deserialize data that was saved with the old version of the assembly.

The second is that it simply cannot find the DLL. There are but a few places where you can store an assembly so that it can be found when VS is running. Either the GAC or the PrivateAssemblies or PublicAssemblies subdirectory of Visual Studio's Common7\IDE directory.

0

精彩评论

暂无评论...
验证码 换一张
取 消