問題描述
Metode Dll tidak dipanggil di windows server 2008 (Dll methods are not invoked on windows server 2008)
I'm trying to invoke on dll method from an ASP.net web. It's working on a W2003 server but the same dll and the same web is crashing on w2008 server R2 with IIS 7.5.I'm doing like this to import the dll:
<DllImport("Cripto.dll")> _
Public Shared Function DesCipher(ByVal uiMode As Integer, ByVal uiLength As Integer, ByVal szSourceData As String) As String
End Function
I have tried a 64 bits dll compile but the problem remains.
I'm going mad...
Please Help!
‑‑‑‑‑
參考解法
方法 1:
Finally I have found the clue. It is a memory location problem. The main function was returning an array like this: char retorno[10000];
The function was declared in the dll code as "char*"
By changing these lines:
ULONG ulSize = strlen((char*)retorno) + sizeof(char);
char* pszReturn = NULL;
pszReturn = (char*)::GlobalAlloc(GMEM_FIXED, ulSize);
strcpy(pszReturn, (char*)retorno);
return pszReturn;
instead of return ((char *)retorno)
Now it's working.