Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Win32 API usage from C# code not working on deployment environment

Win32 API usage from C# code not working on deployment environment

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharpsysadminhelpdotnetvisual-studio
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    impeham
    wrote on last edited by
    #1

    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?

    C 1 Reply Last reply
    0
    • I impeham

      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?

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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 )

      I 1 Reply Last reply
      0
      • C Christian Graus

        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 )

        I Offline
        I Offline
        impeham
        wrote on last edited by
        #3

        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 1 Reply Last reply
        0
        • I impeham

          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 Offline
          I Offline
          impeham
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups