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. C#
  4. app working in window Xp but not in window 7

app working in window Xp but not in window 7

Scheduled Pinned Locked Moved C#
helptutorialquestion
7 Posts 3 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.
  • H Offline
    H Offline
    Hum Dum
    wrote on last edited by
    #1

    It's 32 bit Window application using kernel32.dll for serial port communication. (I know about System.IO.Ports.SerialPort class existence, but application run fine in XP.) In window 7 its not working as expected. I disabled UAC, run as administrator. This started application but some function are not executing properly. Like for GSM modem interface, Modem response for AT command is OK, but in window 7 its not responding for app. But if i use hyper-terminal in win7, its responding for AT. What needs to be done to able to run the app? I tried Google before posting here, but not much help. I think, its kernel32.dll which the app unable to access or window 7 is restricting some function/feature of it? Can any one please guide/help me? regards

    OriginalGriffO L 2 Replies Last reply
    0
    • H Hum Dum

      It's 32 bit Window application using kernel32.dll for serial port communication. (I know about System.IO.Ports.SerialPort class existence, but application run fine in XP.) In window 7 its not working as expected. I disabled UAC, run as administrator. This started application but some function are not executing properly. Like for GSM modem interface, Modem response for AT command is OK, but in window 7 its not responding for app. But if i use hyper-terminal in win7, its responding for AT. What needs to be done to able to run the app? I tried Google before posting here, but not much help. I think, its kernel32.dll which the app unable to access or window 7 is restricting some function/feature of it? Can any one please guide/help me? regards

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      Windows 7 is a lot stricter about hardware access than XP, and this is probably your problem. Have you tried running your app in Compatibility Mode?[^]

      Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      H 1 Reply Last reply
      0
      • OriginalGriffO OriginalGriff

        Windows 7 is a lot stricter about hardware access than XP, and this is probably your problem. Have you tried running your app in Compatibility Mode?[^]

        Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

        H Offline
        H Offline
        Hum Dum
        wrote on last edited by
        #3

        yes i tried that also. but application not working as excepted. After compatibility mode setting, application able to read and write on serial port but unable to access modem status (GSM modem status, its capturing in XP like ring, busy etc).

        [DllImport("kernel32.dll")]
        public static extern Boolean GetCommModemStatus(IntPtr hFile, out UInt32 lpModemStat);

        Also for GSM if i use ATZ command its responding, but not for AT. It has to be with security, access control setting. any other idea. regards

        1 Reply Last reply
        0
        • H Hum Dum

          It's 32 bit Window application using kernel32.dll for serial port communication. (I know about System.IO.Ports.SerialPort class existence, but application run fine in XP.) In window 7 its not working as expected. I disabled UAC, run as administrator. This started application but some function are not executing properly. Like for GSM modem interface, Modem response for AT command is OK, but in window 7 its not responding for app. But if i use hyper-terminal in win7, its responding for AT. What needs to be done to able to run the app? I tried Google before posting here, but not much help. I think, its kernel32.dll which the app unable to access or window 7 is restricting some function/feature of it? Can any one please guide/help me? regards

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Having code execute well on one operating system does not imply the code is correct or good enough. When inexplicable things happen, that tells me you are ignoring success/failure results somewhere. Make sure you look at every return value for system calls (such as the ones you're calling in kernel32.dll), call GetLastError correctly when such a function signals an error, and do not swallow exceptions, always report something is wrong, with the necessary details. And be careful how you handle GetLastError, as the P/Invoke layer interferes with it; I explained it in here[^]. :)

          Luc Pattyn [My Articles] Nil Volentibus Arduum

          H 1 Reply Last reply
          0
          • L Luc Pattyn

            Having code execute well on one operating system does not imply the code is correct or good enough. When inexplicable things happen, that tells me you are ignoring success/failure results somewhere. Make sure you look at every return value for system calls (such as the ones you're calling in kernel32.dll), call GetLastError correctly when such a function signals an error, and do not swallow exceptions, always report something is wrong, with the necessary details. And be careful how you handle GetLastError, as the P/Invoke layer interferes with it; I explained it in here[^]. :)

            Luc Pattyn [My Articles] Nil Volentibus Arduum

            H Offline
            H Offline
            Hum Dum
            wrote on last edited by
            #5

            WRT to you link, i tried but no luck. then i replace hardware card/modem with another one. And on this everything worked as excepted, without any code modification. But same old card is working on XP, also responding to hyper-terminal in win 7. Then i tried SerialPort class of .Net framework 2.0 wrt to this Article and old modem/card responded as excepted in win 7. I am using this article for PI invoke. My question is why its not working in win 7 with PI invoke code. but responding with SerialPort class of .Net 2.0, also to hyper-terminal. Old modem is PCI card, while new is PCI express. Any light/idea you shed highly appreciated. below are query modem log of both old(not working) and new(working) Not Working Query Modem log

            01-06-2012 20:48:20.029 - File: C:\Windows\system32\tapisrv.dll, Version 6.1.7600
            01-06-2012 20:48:20.045 - File: C:\Windows\system32\unimdm.tsp, Version 6.1.7600
            01-06-2012 20:48:20.045 - File: C:\Windows\system32\unimdmat.dll, Version 6.1.7600
            01-06-2012 20:48:20.045 - File: C:\Windows\system32\uniplat.dll, Version 6.1.7600
            01-06-2012 20:48:20.060 - File: C:\Windows\system32\drivers\modem.sys, Version 6.1.7600
            01-06-2012 20:48:20.060 - File: C:\Windows\system32\modemui.dll, Version 6.1.7600
            01-06-2012 20:48:20.060 - File: C:\Windows\system32\mdminst.dll, Version 6.1.7600
            01-06-2012 20:48:20.060 - Modem type: Conexant 56K Voice Modem
            01-06-2012 20:48:20.060 - Modem inf path: oem15.inf
            01-06-2012 20:48:20.060 - Modem inf section: Modem1
            01-06-2012 20:48:20.060 - Matching hardware ID: pci\ven_2003&dev_8800&subsys_280016ef
            01-06-2012 20:48:20.060 - Opening the modem device failed with error 00000020
            ATQ0V1E0 - OK
            AT+GMM - Conexant 56K Voice Modem
            Ver4.20.01AG11
            AT+FCLASS=? - 0,1,2.0,8
            AT#CLS=? - 0,1,2.0,8
            AT+GCI? - +GCI:B5
            AT+GCI=? - +GCI:(B5)
            ATI1 - Conexant 56K Voice Modem
            Conexant
            Ver4.20.01AG11
            Rev
            ATI2 - Conexant
            Ver4.20.01AG11
            Rev
            MV (CID\SPK)
            ATI3 - Conexant
            SL8800 PCI
            ATI4 - Active Profile:
            S00=000 S01=000 S02=043 S03=013 S04=010 S05=008 S06=002 S07=060
            S08=002 S09=006 S10=128 S11=100 S12=050 S13=000 S14=000 S

            L 1 Reply Last reply
            0
            • H Hum Dum

              WRT to you link, i tried but no luck. then i replace hardware card/modem with another one. And on this everything worked as excepted, without any code modification. But same old card is working on XP, also responding to hyper-terminal in win 7. Then i tried SerialPort class of .Net framework 2.0 wrt to this Article and old modem/card responded as excepted in win 7. I am using this article for PI invoke. My question is why its not working in win 7 with PI invoke code. but responding with SerialPort class of .Net 2.0, also to hyper-terminal. Old modem is PCI card, while new is PCI express. Any light/idea you shed highly appreciated. below are query modem log of both old(not working) and new(working) Not Working Query Modem log

              01-06-2012 20:48:20.029 - File: C:\Windows\system32\tapisrv.dll, Version 6.1.7600
              01-06-2012 20:48:20.045 - File: C:\Windows\system32\unimdm.tsp, Version 6.1.7600
              01-06-2012 20:48:20.045 - File: C:\Windows\system32\unimdmat.dll, Version 6.1.7600
              01-06-2012 20:48:20.045 - File: C:\Windows\system32\uniplat.dll, Version 6.1.7600
              01-06-2012 20:48:20.060 - File: C:\Windows\system32\drivers\modem.sys, Version 6.1.7600
              01-06-2012 20:48:20.060 - File: C:\Windows\system32\modemui.dll, Version 6.1.7600
              01-06-2012 20:48:20.060 - File: C:\Windows\system32\mdminst.dll, Version 6.1.7600
              01-06-2012 20:48:20.060 - Modem type: Conexant 56K Voice Modem
              01-06-2012 20:48:20.060 - Modem inf path: oem15.inf
              01-06-2012 20:48:20.060 - Modem inf section: Modem1
              01-06-2012 20:48:20.060 - Matching hardware ID: pci\ven_2003&dev_8800&subsys_280016ef
              01-06-2012 20:48:20.060 - Opening the modem device failed with error 00000020
              ATQ0V1E0 - OK
              AT+GMM - Conexant 56K Voice Modem
              Ver4.20.01AG11
              AT+FCLASS=? - 0,1,2.0,8
              AT#CLS=? - 0,1,2.0,8
              AT+GCI? - +GCI:B5
              AT+GCI=? - +GCI:(B5)
              ATI1 - Conexant 56K Voice Modem
              Conexant
              Ver4.20.01AG11
              Rev
              ATI2 - Conexant
              Ver4.20.01AG11
              Rev
              MV (CID\SPK)
              ATI3 - Conexant
              SL8800 PCI
              ATI4 - Active Profile:
              S00=000 S01=000 S02=043 S03=013 S04=010 S05=008 S06=002 S07=060
              S08=002 S09=006 S10=128 S11=100 S12=050 S13=000 S14=000 S

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              I can't tell what is wrong in your P/Invoke code as you aren't showing any of it. I could guess your problem is one of these: 1. access right problems, Vista/Win7 being more protective of system resources than XP is. 2. Your Win7 probably is 64-bit, whereas your other systems probably are 32-bit, which means your P/Invoke must now correctly handle pointers, e.g. be aware that IntPtr is 32/64 bit depending on OS, whereas a lot of P/Invoke examples wrongly use int to pass pointers. (One way to circumvent this problem is by building for "x86" rather than "AnyCPU"). :)

              Luc Pattyn [My Articles] Nil Volentibus Arduum

              H 1 Reply Last reply
              0
              • L Luc Pattyn

                I can't tell what is wrong in your P/Invoke code as you aren't showing any of it. I could guess your problem is one of these: 1. access right problems, Vista/Win7 being more protective of system resources than XP is. 2. Your Win7 probably is 64-bit, whereas your other systems probably are 32-bit, which means your P/Invoke must now correctly handle pointers, e.g. be aware that IntPtr is 32/64 bit depending on OS, whereas a lot of P/Invoke examples wrongly use int to pass pointers. (One way to circumvent this problem is by building for "x86" rather than "AnyCPU"). :)

                Luc Pattyn [My Articles] Nil Volentibus Arduum

                H Offline
                H Offline
                Hum Dum
                wrote on last edited by
                #7

                Luc Pattyn wrote:

                I can't tell what is wrong in your P/Invoke code as you aren't showing any of it.

                The code is same not a bit change from the article i mention i.e. Use PI invoke for serial communication. Updated code is in download link of article, on MSDN(article) page code is not updated. In case of not working modem ReceiveThread() of CommBase.cs is not behaving as its in working modem.

                eventMask = (uint)Marshal.ReadInt32(uMask);
                //some code

                //not able to get inside this block in not working modem and OnRxChar(buf[0]) event is not raised
                if ((eventMask & Win32Com.EV_RXCHAR) != 0)
                {
                do
                {
                gotbytes = 0;
                if (!Win32Com.ReadFile(hPort, buf, 1, out gotbytes, unmanagedOv))
                {
                int x = Marshal.GetLastWin32Error();
                throw new CommPortException("IO Error [004]");
                }
                if (gotbytes == 1) OnRxChar(buf[0]);
                } while (gotbytes > 0);
                }

                //same for OnStatusChange event is not raised
                uint i = 0;
                if ((eventMask & Win32Com.EV_CTS) != 0) i |= Win32Com.MS_CTS_ON;
                if ((eventMask & Win32Com.EV_DSR) != 0) i |= Win32Com.MS_DSR_ON;
                if ((eventMask & Win32Com.EV_RLSD) != 0) i |= Win32Com.MS_RLSD_ON;
                if ((eventMask & Win32Com.EV_RING) != 0) i |= Win32Com.MS_RING_ON;
                if (i != 0)
                {
                uint f;
                if (!Win32Com.GetCommModemStatus(hPort, out f)) throw new CommPortException("IO Error [005]");
                OnStatusChange(new ModemStatus(i), new ModemStatus(f));
                }

                above are few lines of ReceiveThread for reference which are not executing as excepted.

                Luc Pattyn wrote:

                Your Win7 probably is 64-bit,

                Its 32 bit.

                Luc Pattyn wrote:

                (One way to circumvent this problem is by building for "x86" rather than "AnyCPU").

                This i will try. But have doubt as same code is working in same window 7 but with different card. But not working card respond with .Net 2.0 serial port class under same window 7.

                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