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.