[英]Attempted to read or write protected memory. This is often an indication that other memory is corrupt in c# (Access violation)
[英]DLLImport(C code) C# Attempted to read or write protected memory. This is often an indication that other memory is corrupt”
這是我的DLL導入語句:
[DllImport("KaracellLib.dll", EntryPoint = "karacell_bridge@8", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi, ExactSpelling = true)]
public static extern int karacell_bridge(int argumentCount, string[] argContent);
本機C代碼(轉換為DLL)中的實際函數定義:
int __stdcall karacell_bridge(int argumentCount, char ** argContent )
當我嘗試多次在C#代碼中調用DLL時,出現錯誤消息。
我已經嘗試以下解決錯誤
public static extern int karacell_bridge(int argumentCount, ref string[] argContent);
任何幫助表示贊賞! 謝謝!
問題是因為多個線程正在C#程序中調用karacell_bridge函數。 因此,一旦我解決了這個問題,便修復了異常:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.