Here is the scenario:
I have built a wcf rest 4.0 using VS 2010 online template 40(cs).
I have a web GET method defined which calls a function in native C dll.
[DllImport("DLookupDLL.dll", EntryPoint = "GetDistInfo")]
public static extern bool GetDistInfo(StringBuilder distfile, int input, IntPtr distInfo );
[Description("Returns the details of a descriptor for the input SID.")]
[WebGet(UriTemplate = "service")]
BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)]
public DInfo GetDS(string strS)
{
bool bRet = false;
StringBuilder distFeedfile;
distFeedfile = new StringBuilder(@"C:\DFeeds\DFeed_20.xml");
int input = Convert.ToInt32(strS);
DInfo distInfo;
IntPtr dInfoPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(DInfo)));
try
{
bRet = GetDistInfo(distFeedfile, input, dInfoPtr);
distInfo = (DInfo)(Marshal.PtrToStructure(dInfoPtr, typeof(DInfo)));
return distInfo;
}
finally
{
Marshal.FreeHGlobal(dInfoPtr);
}
}
Everything works fine in my VS Deployment server.
And when I hosted it in my local IIS (with appPool set to net 4.0), first it didn't work, but then after I changed the AppPool settings to enable 32bit (for the native support) and I built the rest service with x86 set, then it worked.
Then I deployed the service on the server, and did similar setting to AppPool. But it gives an 500 error. I know the service is hosted correctly because another simple hello world method works.
Even in the above GetDS method if I comment the call to bRet = GetDistInfo(distFeedfile, input, dInfoPtr);
then the service returns correctly, ofcourse the with structure DInfo with junk data.
What am I missing? Why the native call on the server is not working. Am I missing any settings or installation?
Thanks much in advance.