I wrote a little piece of software that downloads file from internet, that is, nothing more. My intentions are to use it thru the command line... It works great, but when I place it in C:\Windows\System32\ to actually use it from everywhere I want it doesn't work now... It didn't throw an exception... it just show me this messagebox - http://i.imgur.com/a7rlMgo.png and if I click "Yes" it opens this page in the browser - http://support.microsoft.com/kb/2715633/en-us
What should I do to get it working?
The code if it is of any use.. :
private const string InsufficientParametersMessage = "Insufficient Parameters...";
private static string[] _arguments;
static void Main(string[] args)
{
_arguments = args;
TakeCommand();
Environment.Exit(0);
}
private static void TakeCommand()
{
if (_arguments.Length < 1)
{
Console.WriteLine(InsufficientParametersMessage);
}
else if (_arguments.Length == 1)
{
DownloadFile(_arguments[0]);
}
else if (_arguments.Length > 1)
{
DownloadFile(_arguments[0], _arguments[1]);
}
}
private static void DownloadFile(string url)
{
DownloadFile(url, Path.GetFileName(url));
}
private static void DownloadFile(string url, string localFileName)
{
WebClient client = new WebClient();
if (File.Exists(localFileName))
{
File.Delete(localFileName);
}
try
{
client.DownloadFile(url, localFileName);
Console.WriteLine("Done...");
}
catch (Exception exception)
{
Console.WriteLine(exception.Message);
}
}
Short Answer: Uncheck "Prefer 32-bit".
Long Answer: (Not 100% sure but here goes)
Assuming you have a 64 bit machine, keep in mind that System32 is a folder that is reserved for 64 bit application usage, and although it may seem strange, SysWOW64 contains 32 bit dlls and is reserved for 32-bit applications. Typically, 32-bit applications that access System32 will go through a file system redirector to the SysWOW64 folder. More info here.
However, when your application (which runs as a 32-bit process) runs in System32 itself, the redirector probably doesn't do anything because it thinks there isn't any need to redirect, which is why your app works outside of System32 but not inside it.
So to solve this, uncheck Prefer 32-bit so that it will try to target 64 bit platform, ... or better yet, put the app elsewhere and add the application directory to your environment path variable. That way you can still access your application .exe anywhere, and it won't pollute your System32 folder which should only be used for Windows files anyways.
This answer may not be applicable to the OP's problem (which has been solved anyway), but maybe for others who end up here due to a search on “This application could not be started" and System32. In my case I had written a screensaver program in C# that had to run 32-bit, and the solution was to install it in the Windows directory, not Windows\System32. Then it works OK on both 32- and 64-bit systems.
If you put your 32-bit exe in both the System32 and the SysWOW64 folder. It works just fine. Not one, not the other, but both folders.
This might sound strange, but try it. If you put the same exe in both folders it will start up without any modifications.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With