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. VB6 dll calls from WCF

VB6 dll calls from WCF

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharphelpwcfhosting
27 Posts 6 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.
  • E Emanuela Meraglia

    Hi everyone, I created a library of the WCF service, which recalls a VB6 dll. The problem is this: in the procedures of the VB6 dll (not my owner) strange errors occur (especially with dates), if the initial process that hosts it is the WCF service. Everything works correctly if the initial process is a VB6 executable, a VB.NET executable, or if I run the VB6 project in debug. Among the many attempts I set all my projects with CPUs targeting x86, and although I had no problems compiling the WCF service, I also tried to replace WcfSvcHost.exe with the same in 32-bit mode (with the command "corflags / 32BIT + / FORCE WcfSvcHost.exe "), but the problem persists. Actually I don't think it's even necessary, as the hosting of the WCF library is an application console. I have no idea how to solve ... can anyone help me?

    D Offline
    D Offline
    Dave Kreskowiak
    wrote on last edited by
    #11

    VB6 can only make COM-exposed .DLL's. I don't know if that means or affects anything, but there it is. Without seeing the code that's calling the functions in the .DLL, and the error messages coming back from SQL Server, it's going to be impossible to tell you anything useful. The biggest problem is we can see the code in the VB6 .DLL, so we don't know what it expects in the function calls.

    Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
    Dave Kreskowiak

    E 1 Reply Last reply
    0
    • E Emanuela Meraglia

      I don't understand which user you're referring to

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #12

      Environment.UserName All the code runs under specific credentials. Your hosted service may not be running as a default user.

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

      E 1 Reply Last reply
      0
      • D Dave Kreskowiak

        VB6 can only make COM-exposed .DLL's. I don't know if that means or affects anything, but there it is. Without seeing the code that's calling the functions in the .DLL, and the error messages coming back from SQL Server, it's going to be impossible to tell you anything useful. The biggest problem is we can see the code in the VB6 .DLL, so we don't know what it expects in the function calls.

        Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
        Dave Kreskowiak

        E Offline
        E Offline
        Emanuela Meraglia
        wrote on last edited by
        #13

        I do not have the VB6 dll source from my provider, so I have no way of getting the error.
        I am attaching images of errors captured by SQL Profiler, but I don't think they can help.
        The 1.png, 2.png and 3.png files are screenshots of the SQL profiler traces captured at Runtime, while the 1_Debug.png, 2_Debug.png and 3_Debug.png files are screenshots of the SQL profiler traces captured in Debug (so working).

        Since the errors do not occur by calling the VB6 dll from VB6 or VB.NET applications, or by debugging my VB6 project which instantiates the external dll, I thought the problem lies in the process that hosts it.

        https://drive.google.com/open?id=1Wziux18JvKzx-7DtBMTSfrOT5TuANVVF

        L S 2 Replies Last reply
        0
        • L Lost User

          Environment.UserName All the code runs under specific credentials. Your hosted service may not be running as a default user.

          Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

          E Offline
          E Offline
          Emanuela Meraglia
          wrote on last edited by
          #14

          I wrote the current user in my log file, and it matches with the Windows credentials I logged in with ... so it's ok.

          L 1 Reply Last reply
          0
          • E Emanuela Meraglia

            I do not have the VB6 dll source from my provider, so I have no way of getting the error.
            I am attaching images of errors captured by SQL Profiler, but I don't think they can help.
            The 1.png, 2.png and 3.png files are screenshots of the SQL profiler traces captured at Runtime, while the 1_Debug.png, 2_Debug.png and 3_Debug.png files are screenshots of the SQL profiler traces captured in Debug (so working).

            Since the errors do not occur by calling the VB6 dll from VB6 or VB.NET applications, or by debugging my VB6 project which instantiates the external dll, I thought the problem lies in the process that hosts it.

            https://drive.google.com/open?id=1Wziux18JvKzx-7DtBMTSfrOT5TuANVVF

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #15

            Your link points to this page.

            E 1 Reply Last reply
            0
            • L Lost User

              Your link points to this page.

              E Offline
              E Offline
              Emanuela Meraglia
              wrote on last edited by
              #16

              Errori.zip - Google Drive[^]

              L 1 Reply Last reply
              0
              • E Emanuela Meraglia

                I don't have the error because the VB6 dll is not mine, but with SQL profiler I found errors in the queries due to lack or incorrect formatting of dates.

                Richard DeemingR Offline
                Richard DeemingR Offline
                Richard Deeming
                wrote on last edited by
                #17

                Emanuela Meraglia wrote:

                errors in the queries due to lack or incorrect formatting of dates

                That would suggest that the VB6 code is vulnerable to SQL Injection[^]. It it was using properly parameterized queries, date formatting wouldn't be an issue. This is a serious security vulnerability. You should either get the author to rewrite the VB6 code, or find some way to replace it.


                "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

                E 1 Reply Last reply
                0
                • E Emanuela Meraglia

                  I wrote the current user in my log file, and it matches with the Windows credentials I logged in with ... so it's ok.

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #18

                  :thumbsup:

                  Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

                  1 Reply Last reply
                  0
                  • Richard DeemingR Richard Deeming

                    Emanuela Meraglia wrote:

                    errors in the queries due to lack or incorrect formatting of dates

                    That would suggest that the VB6 code is vulnerable to SQL Injection[^]. It it was using properly parameterized queries, date formatting wouldn't be an issue. This is a serious security vulnerability. You should either get the author to rewrite the VB6 code, or find some way to replace it.


                    "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                    E Offline
                    E Offline
                    Emanuela Meraglia
                    wrote on last edited by
                    #19

                    They are rewriting it, but in the meantime I have to use their dll VB6! :(

                    1 Reply Last reply
                    0
                    • E Emanuela Meraglia

                      Errori.zip - Google Drive[^]

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #20

                      All the messages seem to be complaining about the syntax of the SELECT clauses (assuming my innterpretation of the Italian is coorect), and suggesting that it has something to do with the Date values. I think the only way to resolve this is to talk to the owners of the DLL.

                      1 Reply Last reply
                      0
                      • E Emanuela Meraglia

                        Hi everyone, I created a library of the WCF service, which recalls a VB6 dll. The problem is this: in the procedures of the VB6 dll (not my owner) strange errors occur (especially with dates), if the initial process that hosts it is the WCF service. Everything works correctly if the initial process is a VB6 executable, a VB.NET executable, or if I run the VB6 project in debug. Among the many attempts I set all my projects with CPUs targeting x86, and although I had no problems compiling the WCF service, I also tried to replace WcfSvcHost.exe with the same in 32-bit mode (with the command "corflags / 32BIT + / FORCE WcfSvcHost.exe "), but the problem persists. Actually I don't think it's even necessary, as the hosting of the WCF library is an application console. I have no idea how to solve ... can anyone help me?

                        E Offline
                        E Offline
                        Emanuela Meraglia
                        wrote on last edited by
                        #21

                        Checking the VB6 code with the developer, we have identified the point where the error occurs: it cannot return a path of the configuration file (from which it reads the formatting of the dates), and uses the Windows API "GetEnvironmentVariable" .
                        I'm trying to figure out if there is any incompatibility between WCF and the VB6 API calls.

                        Richard DeemingR 1 Reply Last reply
                        0
                        • E Emanuela Meraglia

                          Checking the VB6 code with the developer, we have identified the point where the error occurs: it cannot return a path of the configuration file (from which it reads the formatting of the dates), and uses the Windows API "GetEnvironmentVariable" .
                          I'm trying to figure out if there is any incompatibility between WCF and the VB6 API calls.

                          Richard DeemingR Offline
                          Richard DeemingR Offline
                          Richard Deeming
                          wrote on last edited by
                          #22

                          If you're hosting the WCF service in IIS or a Windows Service, it will be running under a different profile. Unless the environment variable is set as a system variable, it will be specific to your user profile, and will not be available to the WCF code. Environment variables in Windows NT[^]


                          "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

                          E 1 Reply Last reply
                          0
                          • Richard DeemingR Richard Deeming

                            If you're hosting the WCF service in IIS or a Windows Service, it will be running under a different profile. Unless the environment variable is set as a system variable, it will be specific to your user profile, and will not be available to the WCF code. Environment variables in Windows NT[^]


                            "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                            E Offline
                            E Offline
                            Emanuela Meraglia
                            wrote on last edited by
                            #23

                            I'm hosting the WCF service in a windows service

                            Richard DeemingR 1 Reply Last reply
                            0
                            • E Emanuela Meraglia

                              I'm hosting the WCF service in a windows service

                              Richard DeemingR Offline
                              Richard DeemingR Offline
                              Richard Deeming
                              wrote on last edited by
                              #24

                              So unless the environment variable is registered as a "system" variable, it won't be available to the WCF service.


                              "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                              "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

                              1 Reply Last reply
                              0
                              • E Emanuela Meraglia

                                I don't have the error because the VB6 dll is not mine, but with SQL profiler I found errors in the queries due to lack or incorrect formatting of dates.

                                A Offline
                                A Offline
                                andreelew92
                                wrote on last edited by
                                #25

                                Great! Xender Download – Download Xender – The best cross platform file transferring software between iOS & Android[^]

                                1 Reply Last reply
                                0
                                • E Emanuela Meraglia

                                  The error also occurs on my development PC, on which everything is executed. So I don't think it's a problem of regional settings.

                                  S Offline
                                  S Offline
                                  simpledeveloper
                                  wrote on last edited by
                                  #26

                                  Let us reverse Engineer it, I have come across these types of situations a lot time ago. Here is the clue, you said you are able to execute the application and the same dll as exe right? Check what Date formatting is it being used there and one more advice is, go to the stored procedure because you are able to find the stored procedure using the SQL Profiler right? Try to execute the SP by passing the different Parameters and replicate the same error, then you would know what formats the SP is accepting and what formats the sp is giving the errors and why? Then you can fix the issue in the Web Service to use the same format - what you are going through is similar what many have sometime back when everything moved from VB6 to .Net Framework - but its OK. You are doing a great Job - best of Luck.:thumbsup:

                                  1 Reply Last reply
                                  0
                                  • E Emanuela Meraglia

                                    I do not have the VB6 dll source from my provider, so I have no way of getting the error.
                                    I am attaching images of errors captured by SQL Profiler, but I don't think they can help.
                                    The 1.png, 2.png and 3.png files are screenshots of the SQL profiler traces captured at Runtime, while the 1_Debug.png, 2_Debug.png and 3_Debug.png files are screenshots of the SQL profiler traces captured in Debug (so working).

                                    Since the errors do not occur by calling the VB6 dll from VB6 or VB.NET applications, or by debugging my VB6 project which instantiates the external dll, I thought the problem lies in the process that hosts it.

                                    https://drive.google.com/open?id=1Wziux18JvKzx-7DtBMTSfrOT5TuANVVF

                                    S Offline
                                    S Offline
                                    simpledeveloper
                                    wrote on last edited by
                                    #27

                                    What Dave said might be correct too, since Service is to transport the Data it must be Serializable or Distributed that would be a problem but to know the real problem - try to replicate the issue on Stored Proc by passing different Date formats as I can guess you have only one source code that's exposed to you all other are either dlls or exes, which you can't reverse them into VB6 code back. So focus on one Source Code you may probably have or know that's SP and try to replicate the problem.

                                    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