簡體   English   中英

DLLImport(C code)C#嘗試讀取或寫入受保護的內存。 這通常表明其他內存已損壞”

[英]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時,出現錯誤消息。

我已經嘗試以下解決錯誤

  1. 通過進入工具->調試->常規,禁止對模塊負載(受管理的nly)進行JIT優化
  2. 在C#dLL導入定義中添加了ref: public static extern int karacell_bridge(int argumentCount, ref string[] argContent);

任何幫助表示贊賞! 謝謝!

問題是因為多個線程正在C#程序中調用karacell_bridge函數。 因此,一旦我解決了這個問題,便修復了異常:)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM