1

Recently, "out of nowhere", I'm getting an exception when trying to design a previously perfectly openable form in Visual Studio 2017:

The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I also get one or multiple call stack errors:

at System.ComponentModel.ReflectPropertyDescriptor.SetValue(Object component, Object value)
at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkPropertyDescriptor.SetValue(Object component, Object value)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializePropertyAssignStatement(IDesignerSerializationManager manager, CodeAssignStatement statement, CodePropertyReferenceExpression propertyReferenceEx, Boolean reportError)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeAssignStatement(IDesignerSerializationManager manager, CodeAssignStatement statement)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement) 

I'm really confused, sine other dialogs work perfectly and the erroneous dialog worked until yesterday, too.

Compiling and running the application both works successfully.

After trying the solutions of a similar question, I still have no luck resolving this.

My question:

Any idea how to analytically proceed to get to the root cause of this error?

Update 1:

I'm not (only) looking for a direct solution, but preferably for some reliable way of how to get to the root cause of the exception.

From the stack trace, I have no clue what even might cause it.

Update 2, solution:

Thanks to your comments, I was able to solve it by starting a second instance of Visual Studio and attaching it to the first one, thus debugging the first one.

I then enabled the Exception Settings to break on all CLR exceptions (in the second VS instance) and opened the erroneous form in Windows Forms Designer in the first VS instance.

The debugger then stopped at the location where the actual FileLoadException occurred.

I then was able to resolve it by removing some of my own logging code in a base control class that seems to work incorrectly when being ran from within VS WinForms Designer.

I will not delete my question here, since it may serve to others (and myself) as a further reference when googling for the initial error message I've got.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
  • 2
    If it was working yesterday than compare yesterdays version of the file with what is there now and determine which change caused the error. – Rafal Jul 03 '18 at 11:33
  • 1
    Just gonna throw it out there and ask if you have closed VS2017 and reopened again to make sure it not a VS bug? Your linked question I would suggest that you might need to manually delete the dll files from where you are seeing the issue and redeploy – Fuzzybear Jul 03 '18 at 11:33
  • 2
    Try this: **1)** Close all instance of VS **2)** Go to `%appdata%\..\Local\Microsoft\VisualStudio\15.0_a26f780e\ProjectAssemblies` **3)** Delete all folders. **Note:** You may have a different version of VS, but for any version you need to take a look at `ProjectAssemblies` folder. Then open VS and rebuild your solution and then open form designer. – Reza Aghaei Jul 03 '18 at 11:52
  • 1
    Also make sure you have deleted bin and obj folder before reopening VS. – Reza Aghaei Jul 03 '18 at 11:58
  • 1
    Look at your project references, you have to fret about one that has a control class that is used on this form. The InitializeComponent() method in the designer.cs file can show it being used. Focus on the [AssemblyVersion] attribute, be especially wary of any that use a wildcard (like "1.0.*"), that's quite toxic in Winforms. – Hans Passant Jul 03 '18 at 12:14

0 Answers0