Visual Studio 2013 designer trying to load wrong version of project DLL
Asked Answered
P

1

0

I have a visual studio project in a solution that references a class library project from the same solution. The project compiles and executes just fine. However, when I try to open one form in the designer I get a message:

Could not load file or assembly 'MyLibName, Version=1.0.5477.26907, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

However, the current version of the DLL is: 1.0.5510.41110

Why is the designer trying to look for an old version? How can I open my form in the designer?

I've tried removing this library from all the projects that reference it in my project and re-adding it. And, of course, I've tried cleaning and rebuilding the project from scratch. Any help appreciated.

Here's the stack trace:

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) 
Pitanga answered 2/2, 2015 at 7:0 Comment(4)
Maybe in the toolbox?Thermopile
That's an excellent suggestion--the project in question does place items in the toolbox. Not sure how to make it recognize the new version however?Pitanga
Tried a right-click "Reset Toolbox" didn't resolve :-(Pitanga
It is probably still added as a project reference somewhere.Thermopile
P
5

Finally got it--seems I'd accidentally serialized an instantiation of an object from the older library version in a user control's public property on this form.

To resolve the issue:

1) I manually edited the .resx file in notepad and removed the base64 encoded binary data for the accidentally serialized property.

2) I followed the directions here to prevent my property from being serialized in the future, ie. I added this attribute: [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]

Pitanga answered 2/2, 2015 at 8:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.