I have a Revit 2016 plugin written in C# using visual studio Professional 2013 on a 64 bit windows 7 machine. I've been debugging it by starting the debug process in visual studio which in turn calls Revit with a command line argument to start a small project that I use for developing the plugin.
Now for some reason Revit crashes during startup if I try to debug it like this, instead I found out that I can start Revit separately and then in visual studio use debug/attach to process... While I'm happy that I found a workaround it adds unnecessary overhead to an already tedious process (having to restart Revit everytime I wan't to start a new debug session). Separate question here: is there a way to tell Revit to "release" the plugin files and later reload them so that I don't have to close Revit, compile the plugins and then start Revit again?
The debug output when it crashes can be seen in the attached file, the first error seems to be
Code:
A first chance exception of type 'System.BadImageFormatException' occurred in mscorlib.dll
After some googling the most common cause for this seems to be that the project is compiled for the wrong platform. This doesn't help me since I haven't changed the target platform, it has always been the default "Any CPU" and it has been working. I have however tried to change this setting to x64 (and x86) but it doesn't solve the problem.
If I debug with "Enable native code debugging" ticked that line is preceeded by the following which I honestly doesn't understand anything from.
Code:
First-chance exception at 0x000007fefd4dadcd (KernelBase.dll) in Revit.exe: Microsoft C++ exception: EEFileLoadException * __ptr64 at memory location 0x0012ad48.
First-chance exception at 0x000007fefd4dadcd (KernelBase.dll) in Revit.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
First-chance exception at 0x000007fefd4dadcd (KernelBase.dll) in Revit.exe: Microsoft C++ exception: EEFileLoadException * __ptr64 at memory location 0x0012ad48.
First-chance exception at 0x000007fefd4dadcd (KernelBase.dll) in Revit.exe: Microsoft C++ exception: EEFileLoadException * __ptr64 at memory location 0x0012ca00.
First-chance exception at 0x000007fefd4dadcd (KernelBase.dll) in Revit.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
First-chance exception at 0x000007fefd4dadcd (KernelBase.dll) in Revit.exe: Microsoft C++ exception: EEFileLoadException * __ptr64 at memory location 0x0012ca00.
First-chance exception at 0x000007fefd4dadcd (KernelBase.dll) in Revit.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
First-chance exception at 0x000007fefd4dadcd (KernelBase.dll) in Revit.exe: Microsoft C++ exception: EEFileLoadException * __ptr64 at memory location 0x0012ca00.
I have version control of the project via SVN and have reverted to several different revisions to see if there is something in the code that I changed but no success.
I have tried to repair the installations of both Revit and visual studio without any change in behavior.
EDIT:
It turned out that my workaround didn't work that great after all, I can't watch the value of any variables, the hint when I hover over them in the locals pane says that they might be optimized away which is not the case. So I've reverted to debugging by using printouts with Taskdialog.Show().. I'm getting closer and closer to my roots with small embedded systems were your only debugging option is to blink an LED