I made a program and compiled it. It works as expected in the debug folder. I took it out and put it in system32 but it wont run. It gives this error:
.NET Framework Initialization Error
Unable to find a version of the runtime to run this application.
I've tried putting it in it's own folder inside the debug folder and it worked without the other debug files. I've tried running it as an administrator. I know I have the correct .NET Framework version because it is able to run outside of system32. I've tried to run it from somewhere else using the command prompt. I've tried all that but it still doesn't work.
EDIT: I've also tried putting the exe in the windows folder.
This problem is due to the architecture build of the exe x86 vs. x64. The default compile in VS2012 is ANYCPU with prefer x86 ticked.
If your build is as default on a x64 platform it should be copied to c:\windows\syswow64 which is the 32 bit system32 folder. Or the application should have the prefer x86 option removed and be recompiled.
Either way its not a case of you not having the correct framework installed, it is due to Windows on Windows behaviour and compile configuration.
Hope this helps!
来源:https://stackoverflow.com/questions/12993739/why-cant-i-run-my-exe-in-system32