chandrashekhar sharma

chandrashekhar sharma

  • 1.4k
  • 304
  • 6.9k

How to call c++ dll in wcf Service?

Dec 24 2015 1:06 AM
I have written simple method for math function in c and create dll as mathfunction.dll
bellow cose is mathfunction.dll.
 
#include <stdio.h>
extern "C"
{
__declspec(dllexport) int add(int a,int b)
{
return a+b;
}
__declspec(dllexport) int subtract(int a,int b)
{
return a-b;
}
}'
I try to consume mathfunction.dll in wcf service then throw error message.
'An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)'
Bellow code used in wcf service.
public int Sum(int value, int value1)
{
return add(value, value1);
}
[DllImport("MathFunction.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern int add(int num1, int num2);

Answers (1)