Visual studio 2022 -- Running project as release is broken, Running project as debug is not

nope no 1 Reputation point
2022-12-08T17:28:17.057+00:00

I have a program built on visual studio 2022 that depends on a dll.
The dll is compiled (in both a release, and debug version), targeting the same .net pack, and using the same build configuration (from what i can tell).

Let us call this dll Alice.

When i run my executable from visual studio in debug mode, everything runs along just fine.
When i switch over to the release mode (both are cleaned, and built again), i get the following error:

Exception unhandled:
System.Reflections.TargetInvocationException: 'Exception has been thrown by the target of an invocation.'
Inner Exception:
BadImageFormatException: Could not load file or assembly 'Alice, Version=1.5.1.21190, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Furthermore, the console says System.pdb not included (I'm assuming this is because its tried to debug the exception it just threw, but i just wanted to make sure that was true)

Are the release and debug versions using different versions of Alice.dll? Why would this be?

A second question, related to the first:
When my executable is distributed, in the past, as a release version, it worked fine. The debug version however, keeps on triggering windows defender, specifically smart screen, (which is now disabled, to no effect). I was wondering if releasing this as a debug is whats triggering this issue. Thank you.

Edit 1:
Alright, i've solved the first part, but not the second. It turns out that even if the configuration manager says your platform is x86, there's another setting in the project properties that has a "platform target" in the "build" tab that can be something other than what your platform is. I have no idea what these two pieces of information are supposed to mean, but they clearly don't mean what i thought they did. At any rate, the target platform is now ALSO x86, and the release version runs properly.

This just leaves my second question.

What would suddenly cause, on a machine where we install as administrator, into an admin account, windows defender to suddenly block it from running after installed. Even after clicking "run anyway," it's still blocked as "that assembly does not allow partially trusted callers." I googled around a bit, and tried modifying the assemblies mentioned with "allowpartiuallytrusted" but that only stopped the executable from running at all with a security violation. I'm dumbfounded by what could have changed in my installers that would trigger this, as i'm not a windows pro, so any suggestion would be welcome. Thank you.

Developer technologies | Visual Studio | Debugging
Developer technologies | Visual Studio | Other
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.