Visual Studio 2013设计器试图加载错误版本的项目DLL

时间:2015-02-02 07:00:46

标签: dll visual-studio-2013 windows-forms-designer

我在一个解决方案中有一个visual studio项目,它引用了同一解决方案中的类库项目。该项目编译并执行得很好。但是,当我尝试在设计器中打开一个表单时,我收到一条消息:

无法加载文件或程序集' 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) 

1 个答案:

答案 0 :(得分:4)

终于搞定了 - 似乎我不小心在这个表单上的用户控件的公共属性中序列化了旧库版本中对象的实例化。

要解决此问题:

1)我手动编辑了记事本中的.resx文件,并删除了意外序列化属性的base64编码二进制数据。

2)我遵循了here的指示,以防止我的财产在将来被序列化,即。我添加了这个属性: [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]