Win32 API usage from C# code not working on deployment environment
-
I am using VS 2008 to develop a Web service that uses few windows API functions in the server side: [DllImport("User32.dll")] public static extern Int32 FindWindow(String lpClassName, String lpWindowName); [DllImport("User32.dll")] public static extern Int32 SetForegroundWindow(int hWnd); [DllImport("User32.dll")] public static extern Int32 GetForegroundWindow(); In the development environment all is working well. I deployed the web service to another machine with same OS (windows XP SP2) and same .net frameworks installed (no development environment there - Installed 1.1, 2.0, 3.0 and 3.5) and these functions are not working (I used logs to watch their operation separately and they are simply not doing anything). I assume therefore that there is a general problem invoking Win32 API on that machine for some reason. Any ideas how to fix this?
-
I am using VS 2008 to develop a Web service that uses few windows API functions in the server side: [DllImport("User32.dll")] public static extern Int32 FindWindow(String lpClassName, String lpWindowName); [DllImport("User32.dll")] public static extern Int32 SetForegroundWindow(int hWnd); [DllImport("User32.dll")] public static extern Int32 GetForegroundWindow(); In the development environment all is working well. I deployed the web service to another machine with same OS (windows XP SP2) and same .net frameworks installed (no development environment there - Installed 1.1, 2.0, 3.0 and 3.5) and these functions are not working (I used logs to watch their operation separately and they are simply not doing anything). I assume therefore that there is a general problem invoking Win32 API on that machine for some reason. Any ideas how to fix this?
Those calls are pretty old, it seems odd to me that they may not be there. Does nothing happen when you call them ?
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
Those calls are pretty old, it seems odd to me that they may not be there. Does nothing happen when you call them ?
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
Like i described - nothing happens (in deplyment environment) - these functions are called but doesn't do the operation they need to. of course they are there (in the DLLs), but somehow the framework don't really get them...
I made some progress with this: I created an EXE application and Tested FindWindow exactly as it is used from my web service (same call, same parameters, etc.). it works fine (finds the window's handle). I tried changing the user for iis from ASPNET to administrator in the machine.config to see if permissions is the problem ( verified user with process explorer), but even with administrator it is not working... Any ideas? Thanks.
modified on Saturday, June 7, 2008 7:56 PM