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 / C++ / MFC
  4. Conversion from C to C#, Need C# Method Signature

Conversion from C to C#, Need C# Method Signature

Scheduled Pinned Locked Moved C / C++ / MFC
csharpcomhelpquestion
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.
  • A Offline
    A Offline
    akvbsoft
    wrote on last edited by
    #1

    in common.c

    typedef unsigned char UN_Char;
    typedef enum { Valid = 0, Invalid = 1, Unknown = -999 } AppResponseCode;

    Method in SomeApi.C , need to Call from C#

    static AppResponseCode SomeFunction(UN_Char ** vUC1PtrPtr,size_t * vSize1Ptr, UN_Char * vUC2Ptr,size_t vSize2, FILE * inputFile, char * vcharPtr)

    I tried to add reference of provided C application DLL but Error appear

    A Reference to '.....\SomeApi.DLL' could not be added. Please make sure that the file is accessible, and that it is valid assembly or COM Component

    So the other option I have is to use DLLImport

    [DllImport("SomeAPI.dll", CharSet = CharSet.Unicode)]
    public static extern AppResponseCode SomeFunction( ????? ) ;

    But I don't know what parameter types I had to pass for Return and Calling parameters to Call and obtain value from SomeFunction() PS: Though I have source code for Complete C application but I can't re-compile it or modify it, I am only allowed to work with available Exe/DLL

    V V 2 Replies Last reply
    0
    • A akvbsoft

      in common.c

      typedef unsigned char UN_Char;
      typedef enum { Valid = 0, Invalid = 1, Unknown = -999 } AppResponseCode;

      Method in SomeApi.C , need to Call from C#

      static AppResponseCode SomeFunction(UN_Char ** vUC1PtrPtr,size_t * vSize1Ptr, UN_Char * vUC2Ptr,size_t vSize2, FILE * inputFile, char * vcharPtr)

      I tried to add reference of provided C application DLL but Error appear

      A Reference to '.....\SomeApi.DLL' could not be added. Please make sure that the file is accessible, and that it is valid assembly or COM Component

      So the other option I have is to use DLLImport

      [DllImport("SomeAPI.dll", CharSet = CharSet.Unicode)]
      public static extern AppResponseCode SomeFunction( ????? ) ;

      But I don't know what parameter types I had to pass for Return and Calling parameters to Call and obtain value from SomeFunction() PS: Though I have source code for Complete C application but I can't re-compile it or modify it, I am only allowed to work with available Exe/DLL

      V Offline
      V Offline
      vcbeaut
      wrote on last edited by
      #2

      if you make c file to DLL, is not that okay?

      1 Reply Last reply
      0
      • A akvbsoft

        in common.c

        typedef unsigned char UN_Char;
        typedef enum { Valid = 0, Invalid = 1, Unknown = -999 } AppResponseCode;

        Method in SomeApi.C , need to Call from C#

        static AppResponseCode SomeFunction(UN_Char ** vUC1PtrPtr,size_t * vSize1Ptr, UN_Char * vUC2Ptr,size_t vSize2, FILE * inputFile, char * vcharPtr)

        I tried to add reference of provided C application DLL but Error appear

        A Reference to '.....\SomeApi.DLL' could not be added. Please make sure that the file is accessible, and that it is valid assembly or COM Component

        So the other option I have is to use DLLImport

        [DllImport("SomeAPI.dll", CharSet = CharSet.Unicode)]
        public static extern AppResponseCode SomeFunction( ????? ) ;

        But I don't know what parameter types I had to pass for Return and Calling parameters to Call and obtain value from SomeFunction() PS: Though I have source code for Complete C application but I can't re-compile it or modify it, I am only allowed to work with available Exe/DLL

        V Offline
        V Offline
        Victor Nijegorodov
        wrote on last edited by
        #3

        Have a look at [DllImportAttribute Class (System.Runtime.InteropServices) | Microsoft Docs](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.dllimportattribute?redirectedfrom=MSDN&view=netframework-4.7.2) Some more ideas you can get from [c# - How do I resolve "Please make sure that the file is accessible and that it is a valid assembly or COM component"? - Stack Overflow](https://stackoverflow.com/questions/7080447/how-do-i-resolve-please-make-sure-that-the-file-is-accessible-and-that-it-is-a)

        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