Conversion from C to C#, Need C# Method Signature
-
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
-
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
-
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
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)