I have a website built in Visual Studio 2010 in ASP.NET using C#. I've made a DLL in Delphi to be used by this website. The DLL includes some simple functions in StdCall. This has always worked before, but now for some reason I have the most peculiar problem. When I run the website project directly from Visual Studio, everything works perfectly as expected. It opens the DLL and call the functions properly. However, when I'm viewing the website through IIS, I get the following error message when I try to access the DLL:
An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
The DLL is in fact in the bin folder, proper access is set, I've restarted IIS, the application pool, and the entire computer its self, to make sure the application was started properly. Nothing seems to work. Here's how I read the DLL:
The contents of the DLL look like this:
JD Solutions
An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
The DLL is in fact in the bin folder, proper access is set, I've restarted IIS, the application pool, and the entire computer its self, to make sure the application was started properly. Nothing seems to work. Here's how I read the DLL:
Code:
[DllImport("JDWeb.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
public static extern string GetUserFirstName(string ConnectionString, string UserName);
public static string UserFirstName(string UserName)
{
return GetUserFirstName(ConfigurationManager.AppSettings["JDDatabase"].ToString(), UserName);
}
The contents of the DLL look like this:
Code:
function GetUserFirstName(ConnectionString: PChar; UserName: PChar): PChar; stdcall;
var
Q: TADOQuery;
cUserName: String;
R: String;
begin
Result:= '';
cUserName:= UserName;
Q:= TADOQuery.Create(nil);
try
try
Q.ConnectionString:= ConnectionString;
Q.SQL.Text:= 'select * from [User_Profiles] where [UserName] = '''+ cUserName + '''';
Q.Open;
if not Q.IsEmpty then begin
Q.First;
R:= Q.FieldByName('FirstName').AsString;
Result:= PChar(R);
end;
Q.Close;
except
on e: exception do begin
end;
end;
finally
Q.Free;
end;
end;
...
exports
GetUserFirstName;
JD Solutions