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. Visual Basic
  4. C# to VB.NET

C# to VB.NET

Scheduled Pinned Locked Moved Visual Basic
csharptutorialquestion
12 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.
  • M Offline
    M Offline
    mlauahi
    wrote on last edited by
    #1

    Thanks for any guidance. I am working in a gray area that I am not familiar with. I have a DLL by a third party supplier. It has a .H file and a .LIB File. So they have been created in C I am guessing. How do I wrap this DLL so that I call its functions from within VB.NET This is the C# lines from thier example: #ifdef SPOEM_EXPORTS #define SPOEM_API __declspec(dllexport) #else #define SPOEM_API __declspec(dllimport) #pragma message("automatic link to spoem.lib") ' <== add this line #pragma comment(lib, "spoem.lib") ' <== add this line #endif

    C 1 Reply Last reply
    0
    • M mlauahi

      Thanks for any guidance. I am working in a gray area that I am not familiar with. I have a DLL by a third party supplier. It has a .H file and a .LIB File. So they have been created in C I am guessing. How do I wrap this DLL so that I call its functions from within VB.NET This is the C# lines from thier example: #ifdef SPOEM_EXPORTS #define SPOEM_API __declspec(dllexport) #else #define SPOEM_API __declspec(dllimport) #pragma message("automatic link to spoem.lib") ' <== add this line #pragma comment(lib, "spoem.lib") ' <== add this line #endif

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

      mlauahi wrote:

      So they have been created in C I am guessing.

      Or C++

      mlauahi wrote:

      This is the C# lines from thier example:

      Are you sure ? That looks like C to me. p/invoke is how you'd call your dll in C# or VB.NET.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      M 2 Replies Last reply
      0
      • C Christian Graus

        mlauahi wrote:

        So they have been created in C I am guessing.

        Or C++

        mlauahi wrote:

        This is the C# lines from thier example:

        Are you sure ? That looks like C to me. p/invoke is how you'd call your dll in C# or VB.NET.

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        M Offline
        M Offline
        mlauahi
        wrote on last edited by
        #3

        Thanks for your fast reply: I have tried: _ Public Shared Function InitParameter(ByVal chSPDir As char) End Function _ Public Shared Function ExitSpDll() End Function _ Public Shared Function USBCommunication() As BOOLEAN End Function etc..... It says that it cannot find the DLL. I have Spoem.dll, spoem.h, and spoem.lib in the project directory. How do I point this class to the DLL.

        M 1 Reply Last reply
        0
        • M mlauahi

          Thanks for your fast reply: I have tried: _ Public Shared Function InitParameter(ByVal chSPDir As char) End Function _ Public Shared Function ExitSpDll() End Function _ Public Shared Function USBCommunication() As BOOLEAN End Function etc..... It says that it cannot find the DLL. I have Spoem.dll, spoem.h, and spoem.lib in the project directory. How do I point this class to the DLL.

          M Offline
          M Offline
          mlauahi
          wrote on last edited by
          #4

          I am using _ This line did not appear on the last post

          1 Reply Last reply
          0
          • C Christian Graus

            mlauahi wrote:

            So they have been created in C I am guessing.

            Or C++

            mlauahi wrote:

            This is the C# lines from thier example:

            Are you sure ? That looks like C to me. p/invoke is how you'd call your dll in C# or VB.NET.

            Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

            M Offline
            M Offline
            mlauahi
            wrote on last edited by
            #5

            Hello Christain I cannot add a reference to the DLL, it says that it is invalid. I have tried both the DLLIMPORT,and then a simpe Declare It says that it cannot locate the DLL. Where does the DLL need to reside, and how do I tell my class where it is?? Thanks

            C 1 Reply Last reply
            0
            • M mlauahi

              Hello Christain I cannot add a reference to the DLL, it says that it is invalid. I have tried both the DLLIMPORT,and then a simpe Declare It says that it cannot locate the DLL. Where does the DLL need to reside, and how do I tell my class where it is?? Thanks

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

              You have a dll, or not ? A h and a lib is useless to you in this instance. You'd have to write C++/CLI code that imports those files and exposes a managed class. If you have a dll, you can't add a reference, that's for COM only.

              Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

              M 1 Reply Last reply
              0
              • C Christian Graus

                You have a dll, or not ? A h and a lib is useless to you in this instance. You'd have to write C++/CLI code that imports those files and exposes a managed class. If you have a dll, you can't add a reference, that's for COM only.

                Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                M Offline
                M Offline
                mlauahi
                wrote on last edited by
                #7

                I copied the SPOEM.DLL to my System32 directory, It now finds the DLL, but it cannot locate the designated Entry Point. One of the function calls is SPOEM.USBCommunication(). When I call this is says: Unable to find an entry point named 'USBCommunication' in DLL 'Spoem' ANy suggestions at this point???

                C 1 Reply Last reply
                0
                • M mlauahi

                  I copied the SPOEM.DLL to my System32 directory, It now finds the DLL, but it cannot locate the designated Entry Point. One of the function calls is SPOEM.USBCommunication(). When I call this is says: Unable to find an entry point named 'USBCommunication' in DLL 'Spoem' ANy suggestions at this point???

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

                  Perhaps the DLL is not exporting it properly. But, if it can be called from C++, it would be usable with p/invoke. You should NEVER copy stuff to System32. Just put it in the directory with the exe.

                  Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                  M 1 Reply Last reply
                  0
                  • C Christian Graus

                    Perhaps the DLL is not exporting it properly. But, if it can be called from C++, it would be usable with p/invoke. You should NEVER copy stuff to System32. Just put it in the directory with the exe.

                    Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                    M Offline
                    M Offline
                    mlauahi
                    wrote on last edited by
                    #9

                    Im am stuck right now. The example code that they give you with this is indeed a C++ 6.0 MFC wizard application. They company supplys the .H, .LIB, and the .dll files. The example just shows those original #DEFINE statements, and there is the exported class for the DLL. I am trying to make the DLL wotk in VB.NET. I am not sure why I am getting an: Unable to find an entry point named 'USBCommunication' in DLL 'Spoem.Dll'. If I am understanding you at this point. I do not use the .H or the .LIB. I should only use the

                    C 1 Reply Last reply
                    0
                    • M mlauahi

                      Im am stuck right now. The example code that they give you with this is indeed a C++ 6.0 MFC wizard application. They company supplys the .H, .LIB, and the .dll files. The example just shows those original #DEFINE statements, and there is the exported class for the DLL. I am trying to make the DLL wotk in VB.NET. I am not sure why I am getting an: Unable to find an entry point named 'USBCommunication' in DLL 'Spoem.Dll'. If I am understanding you at this point. I do not use the .H or the .LIB. I should only use the

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

                      Did you look into how to do pinvoke in VB.NET ? I have no idea, but I'm pretty sure none of your code has tried it, as none has specified the dll name, that I can recall seeing. Here is an example I found online: Public Declare Function BitBlt Lib "gdi32.dll" (hdc As IntPtr , nXDest As Integer, nYDest As integer, nWidth As Integer, nHeight As Integer, hdcSrc As IntPtr, nXSrc As Integer, nYSrc As Integer, dwRop As TernaryRasterOperations) As Boolean Note the Lib "gdi32.dll", that's how to tell VB to load this function from a dll.

                      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                      M 1 Reply Last reply
                      0
                      • C Christian Graus

                        Did you look into how to do pinvoke in VB.NET ? I have no idea, but I'm pretty sure none of your code has tried it, as none has specified the dll name, that I can recall seeing. Here is an example I found online: Public Declare Function BitBlt Lib "gdi32.dll" (hdc As IntPtr , nXDest As Integer, nYDest As integer, nWidth As Integer, nHeight As Integer, hdcSrc As IntPtr, nXSrc As Integer, nYSrc As Integer, dwRop As TernaryRasterOperations) As Boolean Note the Lib "gdi32.dll", that's how to tell VB to load this function from a dll.

                        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                        M Offline
                        M Offline
                        mlauahi
                        wrote on last edited by
                        #11

                        Thats exactly what I did, and it complained about not finding the entry point in the DLL. The example I had was "USBComunication", it said that it could not locate the entry point in the DLL

                        C 1 Reply Last reply
                        0
                        • M mlauahi

                          Thats exactly what I did, and it complained about not finding the entry point in the DLL. The example I had was "USBComunication", it said that it could not locate the entry point in the DLL

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

                          OK, perhaps the DLL doesn't expose the entry point. To build a DLL with entry points, you need a seperate text file that defines them.

                          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                          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