C objects in C#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • esunder
    New Member
    • Jun 2007
    • 4

    C objects in C#

    Here is my current situation.

    I have a DLL, (written in C), that has internal classes. When writing an application that uses the DLL, you create an object and then functions in the DLL operate on the object. 2 of the classes are a connection class and a file class.

    Now I would like to create a C# wrapper for the DLL to broaden the availability of it. I know that I need to use dllimport to access the functions in the dll. But how to I create those objects that are in the dll?

    The C# application will not know about the connection or file class when compiling and will fail because the new declaration is of an unknown type?
  • nmsreddi
    Contributor
    • Jul 2006
    • 366

    #2
    Hello

    i dint get how a C PROGRAM CONTAIN CLASSES IN IT

    THE DLL YOU ARE USING IS DEVELOPED IN C OR C++

    Comment

    • esunder
      New Member
      • Jun 2007
      • 4

      #3
      Well lets assume both cases because I am actually not sure. If it is written in pure C then it has structs, not classes correct? So how can I have a pointer to a C struct.

      If the DLL is C++, then it could have classes or it could have structs, if it has structs, fine, i use the above answer. If it uses classes, how do I go about having an instance of a C++ class in c#? Or is this even possible?

      I will find out for sure though.

      Thanks

      Comment

      • esunder
        New Member
        • Jun 2007
        • 4

        #4
        It is C++, the source code for the DLL has "class" declarations in it.

        Comment

        • nmsreddi
          Contributor
          • Jul 2006
          • 366

          #5
          Hello

          If the DLL contains classes you can defnately access all public members ,of that, just first add the reference to your application ,as the DLL is developed by you ,you will be knowing all the existed in that DLL(probably) so just make an instance of each class you need ,you can access all the public members ,

          Comment

          • esunder
            New Member
            • Jun 2007
            • 4

            #6
            How do I "Add it as a reference" ?

            Thanks

            Comment

            Working...