Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/145.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# System.AccessViolationException调用c++;来自C的函数# 我的C语言应用程序使用DLL导入标签调用外部DLL的C++函数: [DllImport("UserAuthentication.dll")] private static extern int Validate(string pScrambeled, string szReadable, int flToUpper, string pstrErr); int WINAPI ValidateAMOSBS(TCHAR *pScrambeled, TCHAR* szReadable, int flToUpper, TCHAR *pstrErr)_C#_C++_Pinvoke - Fatal编程技术网

C# System.AccessViolationException调用c++;来自C的函数# 我的C语言应用程序使用DLL导入标签调用外部DLL的C++函数: [DllImport("UserAuthentication.dll")] private static extern int Validate(string pScrambeled, string szReadable, int flToUpper, string pstrErr); int WINAPI ValidateAMOSBS(TCHAR *pScrambeled, TCHAR* szReadable, int flToUpper, TCHAR *pstrErr)

C# System.AccessViolationException调用c++;来自C的函数# 我的C语言应用程序使用DLL导入标签调用外部DLL的C++函数: [DllImport("UserAuthentication.dll")] private static extern int Validate(string pScrambeled, string szReadable, int flToUpper, string pstrErr); int WINAPI ValidateAMOSBS(TCHAR *pScrambeled, TCHAR* szReadable, int flToUpper, TCHAR *pstrErr),c#,c++,pinvoke,C#,C++,Pinvoke,仅在一台服务器上,当IIS上托管的ASP.NET应用程序调用它时,它抛出System.AccessViolationException。 我们试图更改X86、X64编译,并重新安装VC++可再发行版本,但没有成功。你有什么建议吗 谢谢 Davide我不知道您的函数ValidateAMOSBS如何详细工作。例如,如果最后一个参数TCHAR是为错误消息分配的缓冲区,那么在导入中,您应该使用StringBuilder类型: [DllImport("UserAuthentication.dll", Ca

仅在一台服务器上,当IIS上托管的ASP.NET应用程序调用它时,它抛出System.AccessViolationException。 我们试图更改X86、X64编译,并重新安装VC++可再发行版本,但没有成功。你有什么建议吗

谢谢


Davide

我不知道您的函数
ValidateAMOSBS
如何详细工作。例如,如果最后一个参数
TCHAR
是为错误消息分配的缓冲区,那么在导入中,您应该使用
StringBuilder
类型:

[DllImport("UserAuthentication.dll", CallingConvention = CallingConvention.Cdecl)]
    private static extern int Validate(string pScrambeled, string szReadable, int flToUpper, StringBuilder pstrErr);
在调用
Validate
函数之前,应该为错误消息分配缓冲区:

StringBuilder pstrErr= new StringBuilder(1000);
其他
TCHAR
参数(如有必要)也是如此

可能重复的