Visual Studio 2013 设计器试图加载错误版本的项目 DLL
Visual Studio 2013 designer trying to load wrong version of project DLL
我在一个解决方案中有一个 visual studio 项目,它引用了同一解决方案中的一个 class 库项目。该项目编译和执行得很好。但是,当我尝试在设计器中打开一个表单时,我收到一条消息:
无法加载文件或程序集 'MyLibName, Version=1.0.5477.26907, Culture=neutral, PublicKeyToken=null' 或其依赖项之一。该系统找不到指定的文件。
但是,当前的DLL版本是:1.0.5510.41110
为什么设计师要找旧版本?如何在设计器中打开我的表单?
我已经尝试从我的项目中引用它的所有项目中删除这个库并重新添加它。而且,当然,我已经尝试从头开始清理和重建项目。任何帮助表示赞赏。
这是堆栈跟踪:
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at System.UnitySerializationHolder.GetRealObject(StreamingContext context)
at System.Runtime.Serialization.ObjectManager.ResolveObjectReference(ObjectHolder holder)
at System.Runtime.Serialization.ObjectManager.DoFixups()
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 System.Resources.ResXDataNode.GenerateObjectFromDataNodeInfo(DataNodeInfo dataNodeInfo, ITypeResolutionService typeResolver)
at System.Resources.ResXDataNode.GetValue(ITypeResolutionService typeResolver)
at System.Resources.ResXResourceReader.ParseDataNode(XmlTextReader reader, Boolean isMetaData)
at System.Resources.ResXResourceReader.ParseXml(XmlTextReader reader)
终于明白了——我似乎不小心在这个表单的用户控件 public 属性 中从旧库版本中序列化了一个对象的实例化。
解决问题:
1) 我在记事本中手动编辑了 .resx 文件,并删除了意外序列化的 base64 编码二进制数据 属性.
2) 我按照指示 here 来防止我的 属性 将来被序列化,即。我添加了这个属性:
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
我在一个解决方案中有一个 visual studio 项目,它引用了同一解决方案中的一个 class 库项目。该项目编译和执行得很好。但是,当我尝试在设计器中打开一个表单时,我收到一条消息:
无法加载文件或程序集 'MyLibName, Version=1.0.5477.26907, Culture=neutral, PublicKeyToken=null' 或其依赖项之一。该系统找不到指定的文件。
但是,当前的DLL版本是:1.0.5510.41110
为什么设计师要找旧版本?如何在设计器中打开我的表单?
我已经尝试从我的项目中引用它的所有项目中删除这个库并重新添加它。而且,当然,我已经尝试从头开始清理和重建项目。任何帮助表示赞赏。
这是堆栈跟踪:
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at System.UnitySerializationHolder.GetRealObject(StreamingContext context)
at System.Runtime.Serialization.ObjectManager.ResolveObjectReference(ObjectHolder holder)
at System.Runtime.Serialization.ObjectManager.DoFixups()
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 System.Resources.ResXDataNode.GenerateObjectFromDataNodeInfo(DataNodeInfo dataNodeInfo, ITypeResolutionService typeResolver)
at System.Resources.ResXDataNode.GetValue(ITypeResolutionService typeResolver)
at System.Resources.ResXResourceReader.ParseDataNode(XmlTextReader reader, Boolean isMetaData)
at System.Resources.ResXResourceReader.ParseXml(XmlTextReader reader)
终于明白了——我似乎不小心在这个表单的用户控件 public 属性 中从旧库版本中序列化了一个对象的实例化。
解决问题:
1) 我在记事本中手动编辑了 .resx 文件,并删除了意外序列化的 base64 编码二进制数据 属性.
2) 我按照指示 here 来防止我的 属性 将来被序列化,即。我添加了这个属性: [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]