4
votes

I am developing a 32bit WinForm app (target: .NET 3.5). My client insists the app be installed into "Windows\System32\clientname" folder and autostarts on startup. Also, the app must be 32bit, so I can't use "Any CPU".

I am developing under Win7 x64 with VS2010 and all versions of .NET are installed. When I start the app I get the message "Unable to find a version of runtime to run this application". On Win7 x86 it works without problem. It's not the app itself and I am 100% sure all the required frameworks are installed.

I know that on a x64 system this folder is not to be used for 32bit apps but as I said: client insists and won't budge.

Before I tell client definitively that it can't be done I want to explore all options. I googled of course and also searched this fine site but nothing helpful for my particular situation came up.

My app spawns another 32bit process located in the same folder. On x64 that didn't work either, of course, but I solved that by using "Wow64DisableWow64FsRedirection" and then copying it to another location to start it from there (which works fine). I have done my homework but I just can't find a solution for starting the main app under x64 and in that particular folder.

Is there one?

1
Why can't you use Any CPU? I bet that's the problem on your 64 bit system, and it won't harm running on a 32bit system at all.antlersoft
Does the client have a reason for wanting it there? Without wanting to sound patronising I assume that you've explained to him that C:\Windows is for Windows, not for applications.Andrew Cooper
I wouldn't worry about sounding patronising @AndrewCooper. I'll bet that not managing to ask it without sounding patronising was the OPs problem too! ;)Jon Hanna
The app must be 32bit because it uses a 3rd part 32bit DLL. Of course I educated client with my limited diplomatic skills :). So, let's just assume all of those conditions are unchangeable. My question is: can it be done (using whatever tricks) or is it definitely not possible?Harald
Here's an argument that may persuade your client, but your client sounds unreasonable. All applications link to system DLLs. The first place that the loader looks for those DLLs is the directory in which the executable resides. That directory will have 64 bit DLLs which cannot be loaded into a 32 bit process.David Heffernan

1 Answers

3
votes

In an attempt to solve this problem I created two folders on my Win7 x64 machine:

  • C:\Windows\System32\ClientName; and
  • C:\Windows\SysWOW64\ClientName

Next I created a simple x86 WinForms application targeting .NET 3.5. I found that if I copied the executable to C:\Windows\System32\ClientName I got exactly the same error message as you reported.

However, if I copied the executable to both directories, then I could start it from C:\Windows\System32\ClientName, and it worked just fine.

I did not try this, but I suspect that if you have a multi-assembly application, you only need to copy the *.exe file to C:\Windows\System32\ClientName. All of the other files (and the EXE) would then reside in the C:\Windows\SysWOW64\ClientName directory.

This is a bit of an untidy solution, I know, but then again your client's requirement is a bit unusual to start with.