How do I create a C dll to use in VS2005 C#?

Discussion in 'OT Technology' started by misha, Mar 21, 2007.

  1. misha

    misha New Member

    Joined:
    Apr 27, 2002
    Messages:
    13,685
    Likes Received:
    0
    Location:
    ATL
  2. whup

    whup I wish you had children and.. so that I could step

    Joined:
    Feb 12, 2007
    Messages:
    1,603
    Likes Received:
    0
    So what's your motivation here. Do you have some C code you want to use in .NET? Any specific reason why you can't port the code to C# (too much work, not your code etc?).

    Port it to C# I recommend, otherwise you need to research COM Interop if porting isn't viable for any reason.

    Also, are you able to compile a dll of the C code currently or you need help with that too?
     
  3. gnp

    gnp New Member

    Joined:
    Mar 11, 2007
    Messages:
    280
    Likes Received:
    0
    if you can manage to make the c dll com compliant. idk shit about doing that in c, i know you need to implement IUnkown (addRef, releaseRef, and 1 other), but i am not sure how to go about that outside of mfc. Anyway if it is com enabled then all you would do is add it as a reference to your .net assembly and the vs ide will create an interop wrapper dll that will allow you to use it from the managed code.

    One option is to use platform invoke, or declares for vb.net

    The other thing to look at is the [DLLImports] attribute if the c class is configured for that
     
  4. misha

    misha New Member

    Joined:
    Apr 27, 2002
    Messages:
    13,685
    Likes Received:
    0
    Location:
    ATL
    it is not my code. will the c code work directly in c#? meaning can I just paste it into a class?
     

Share This Page