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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Adding unmanged code to VB.NET

Adding unmanged code to VB.NET

Scheduled Pinned Locked Moved Visual Basic
helpcsharpc++com
6 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.
  • N Offline
    N Offline
    Nanda1605
    wrote on last edited by
    #1

    Hi, I am trying to add a 3rd party dll(C++) to my application which is created on vb.net. when i tried to add that dll as reference i got a error as "A reference to could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component." When i checked this in online, it seems to be unmanged code which is not accepted by .net and also they said P/Invoke command something like that. But actually i dont know how to register a dll or use Pinvoke method or how i add a unmanged dll into my application, Can anyone help in this.

    Thanks, Nanda

    L 1 Reply Last reply
    0
    • N Nanda1605

      Hi, I am trying to add a 3rd party dll(C++) to my application which is created on vb.net. when i tried to add that dll as reference i got a error as "A reference to could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component." When i checked this in online, it seems to be unmanged code which is not accepted by .net and also they said P/Invoke command something like that. But actually i dont know how to register a dll or use Pinvoke method or how i add a unmanged dll into my application, Can anyone help in this.

      Thanks, Nanda

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

      Register a dll using regsvr32.exe. Do you know the functions exported by the dll?

      N 1 Reply Last reply
      0
      • L Lost User

        Register a dll using regsvr32.exe. Do you know the functions exported by the dll?

        N Offline
        N Offline
        Nanda1605
        wrote on last edited by
        #3

        Thanks JZ, But again. how to do that with regsrv32.exe, for example my dll name is nanda.dll, where i have to do this and how and what was the output

        Thanks, Nanda

        D 1 Reply Last reply
        0
        • N Nanda1605

          Thanks JZ, But again. how to do that with regsrv32.exe, for example my dll name is nanda.dll, where i have to do this and how and what was the output

          Thanks, Nanda

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

          REGSVR32 filename.dll

          But, if the .DLL is not COM-based, this wont work and you'll be forced to use P/Invoke to call the functions in the .DLL. You will not be able to set a reference to it and have VS import the functions for you.

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007, 2008

          N 1 Reply Last reply
          0
          • D Dave Kreskowiak

            REGSVR32 filename.dll

            But, if the .DLL is not COM-based, this wont work and you'll be forced to use P/Invoke to call the functions in the .DLL. You will not be able to set a reference to it and have VS import the functions for you.

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                 2006, 2007, 2008

            N Offline
            N Offline
            Nanda1605
            wrote on last edited by
            #5

            Thanks Dave, I tried but It throws a message box <dll> was loaded, but the DllRegisterServer entry point was not found. This file can not be registered. I hope this dll is not com based Can you please help me how to use P/Invoke with an example.

            Thanks, Nanda

            D 1 Reply Last reply
            0
            • N Nanda1605

              Thanks Dave, I tried but It throws a message box <dll> was loaded, but the DllRegisterServer entry point was not found. This file can not be registered. I hope this dll is not com based Can you please help me how to use P/Invoke with an example.

              Thanks, Nanda

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

              You got that error because the .DLL is not COM-based. You'll have to use P/Invoke to get at the functions in that library. I hope you have the documentation on it. http://www.pinvoke.net[^] has tons of examples.

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                   2006, 2007, 2008

              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