3

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.

Daffy
  • 841
  • 9
  • 23
  • Why do you want to put it in the System32 folder? – Tim Schmelter Oct 20 '12 at 23:58
  • 1
    Possible duplicate of [this one](http://stackoverflow.com/questions/8739595/running-a-console-application-from-the-system32-folder). – Victor Zakharov Oct 20 '12 at 23:59
  • please keep in mind, that .NET exe files are not "real" programs made with native code. They require additional framework and sometimes some other features. – Ivan Kuckir Oct 21 '12 at 00:02
  • @TimSchmelter I want to put it in the System32 folder to make it run using the command prompt from anywhere. This has worked in the past on windows 7, I have no idea why it isn't working now. – Daffy Oct 21 '12 at 00:04
  • It may have worked it was not supported. And its well documented – deleted_user Oct 21 '12 at 00:07
  • @stackmonster Ok, well, is there a way I can have my application be run from anywhere in the command prompt? Like notepad or calc is. – Daffy Oct 21 '12 at 00:09
  • Add your application directory to the user or system path. The supported manner is to not use system folders for application deployment at all. – deleted_user Oct 21 '12 at 00:11
  • 2
    Actually Im going to delete my answer I think the duplicate that @Neolisk pointed out is probably correct. The application configuration is probably missing or incorrect. However I stand by what I said - do not deploy applications or anything else into system32 on windows. Its one of the worst practices in windows app deployment. – deleted_user Oct 21 '12 at 00:17

1 Answers1

6

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!

Daniel Card
  • 61
  • 1
  • 2