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. How to call unmanaged Dll in C#

How to call unmanaged Dll in C#

Scheduled Pinned Locked Moved C#
csharpc++tutorialquestion
3 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.
  • P Offline
    P Offline
    phijophlip
    wrote on last edited by
    #1

    Hi I written a C++ unmanaged Dll. I tried to call the dll in C# Application. But I am unable to call the dll. Kindly note the following points 1) I have used the namespace using System.Runtime.InteropServices; 2) I have used the [DllImport("dll1.dll")] to import the the dll in C#. 3) I tried add the dll in C++ using the Add Reference method.Using this method I was unable to add the dll to the project. The dll is a Win32 Dynamic Dll. Can any one tell how to write a dll in C++ that used imported to C# application ? It is very urgent. Thanks Phijo Philip :)

    C C 2 Replies Last reply
    0
    • P phijophlip

      Hi I written a C++ unmanaged Dll. I tried to call the dll in C# Application. But I am unable to call the dll. Kindly note the following points 1) I have used the namespace using System.Runtime.InteropServices; 2) I have used the [DllImport("dll1.dll")] to import the the dll in C#. 3) I tried add the dll in C++ using the Add Reference method.Using this method I was unable to add the dll to the project. The dll is a Win32 Dynamic Dll. Can any one tell how to write a dll in C++ that used imported to C# application ? It is very urgent. Thanks Phijo Philip :)

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

      You need to pinvoke it, that is, you need to import the methods you want to call, not just the dll. www.pinvoke.net has examples of how to do this with Win32 API calls, the approach for your own calls would be identical.

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

      1 Reply Last reply
      0
      • P phijophlip

        Hi I written a C++ unmanaged Dll. I tried to call the dll in C# Application. But I am unable to call the dll. Kindly note the following points 1) I have used the namespace using System.Runtime.InteropServices; 2) I have used the [DllImport("dll1.dll")] to import the the dll in C#. 3) I tried add the dll in C++ using the Add Reference method.Using this method I was unable to add the dll to the project. The dll is a Win32 Dynamic Dll. Can any one tell how to write a dll in C++ that used imported to C# application ? It is very urgent. Thanks Phijo Philip :)

        C Offline
        C Offline
        CooperWu
        wrote on last edited by
        #3

        I write a dll in VB6.0, and call the dll in c# app. the only thing I done is added the reference to c# app references. (using 'Browse' tab in the 'Add Reference' dialog). hoping this help.

        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