Search code examples
c#visual-studioreference

Unable to add an EXE file as a reference to a project in Visual Studio 2022


I am trying to add an .exe file 'Hearthstonedecktracker.exe' to a plugin that I cloned into Visual Studio 2022. I can find the exe just fine but I get the following error:

enter image description here

Please make sure that the file is accessible, and that it is a valid assembly or COM component

I've made sure that the file is accessible, and according to the documentation, the exe should be able to be added as a reference to C# projects, so I'm confused why I'm getting this error and if there's anything that can be done to fix it.

My only thought is that maybe it's because its in a different hard drive than the exe, but I don't think that should matter. Otherwise I haven't been able to find any documentation on what to do in this scenario, because I need to implement classes from this exe in my project.

Thanks.


Solution

  • What you are referring to should not be the assembly generated by .net but the C++ launcher/updater exe generated by Squirrel. This cannot be added to the Reference of a .net project.

    What you need to reference is %LOCALAPPDATA%\HearthstoneDeckTracker\app-1.6.3\HearthstoneDeckTracker.exe.

    Reference from: https://github.com/HearthSim/Hearthstone-Deck-Tracker/issues/3635