Visual Studio Professional 15.9.2 crashes when opening a custom user control in the designer


My .Net Framework WinForms app builds without errors and runs without errors.

The VS2017 Professional 15.9.2 designer crashes when I double-click to open user controls I've created. These user controls all inherit from a class named MyUserControl. I can open MyUserControl in the designer without an error.

When I run VS2017 alone (no second copy with the debugger attached), I see the following exception when I double-click the target user control:

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

The target user control does not reference MyEventArgs. Adding a reference in the target project to MyEventArgs doesn't help. All references to MyEventArgs in the solution are references to a DLL in a Libraries folder, not project references.

I opened each of the .csproj files in the solution in Notepad. None of them refer to a specific version of the MyEventArgs DLL.

I have cleared all the obj and bin directories.

I have cleared the ProjectAssemblies directory. This is a WinForms app, so no need to clear the temporary ASP.Net files directory.

I started a second copy of VS2017 and attached the debugger to the VS2017 instance where I try to open the user control in the designer. I checked the parent check box to choose to break on all CLR exceptions.

I double-click to open the target user control in the VS designer of the first VS instance.

First I get an exception

The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

with no info on what parameter is incorrect. I looked in all the properties of the exception object. None of my DLLs have the "downloaded from the Internt" bit set.

I click Continue in the debugger, then get this exception

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

=== Pre-bind state information === LOG: DisplayName = MyEventArgs, Version=1.0.6896.23135, Culture=neutral, PublicKeyToken=null (Fully-specified) LOG: Appbase = file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/Common7/IDE/ LOG: Initial PrivatePath = NULL Calling assembly : (Unknown). === LOG: This bind starts in default load context. LOG: Using application configuration file: C:\Users\Adam\AppData\Local\Microsoft\VisualStudio\15.0_fdc9bc52\devenv.exe.config LOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind). LOG: The same bind was seen before, and was failed with hr = 0x80070002.

However, I don't have this version of MyEvents anywhere. All references are to the DLL in the Libraries folder. This DLL has a newer version.

How do I get VS2017 to stop looking for this old version of the DLL?

I ran two copies of AstroGrep (free Windows utility) to search for that version number (1.0.6896.23135) in all files on my C drive as well as the D drive, where the solution is stored. It did not find any instances of this version number in any file (csproj, etc.).

The target user control project does not reference MyEventArgs. I checked each csproj in the solution. All reference a copy of MyEventArgs.dll in a library folder. This copy has a newer version than the one named in the exception.

MyEventArgs is not in the GAC on the target machine.

Where is VS getting this old version number from? If I knew where VS was reading this version number, I could clear it or change it. It can't have made up this number, but I can't find where it is stored.

asked on Stack Overflow Nov 24, 2018 by MindModel • edited Nov 24, 2018 by Uwe Keim

1 Answer


TLDR: This was my fault, not Visual Studio's. That said, a more human-readable exception would have saved me a lot of debugging time.

The exception was caused by the fact that I recently revised my solution by changing many project references to refer to DLLs in a Libraries folder rather than to other projects in the same solution.

For example, I have many projects which contain simple interfaces (IDoStuff). I figured these don't change often, so maybe referring to DLLs would speed up the compile process a bit.

What I believe happened was that I compiled MyEventArgs, creating version 1.0.6896.23135, then compiled other classes which depend on MyEventArgs, then put those DLLs in my Libraries folder. Then I must have re-compiled MyEventArgs, and stored a newer version in the Libraries folder.

I assumed if I had all my project references set to not require specific versions, it would all just work.

I spent hours looking for the "1.0.6896.23135" reference in project files, clearing bin folders, etc.

I now believe that the reference to that specific version of MyEventArgs was embedded in another DLL which I had copied to the Libraries folder.

I revised my solution to go back to using project references and the VS designer no longer crashes when opening the target user controls.

answered on Stack Overflow Nov 25, 2018 by MindModel

User contributions licensed under CC BY-SA 3.0