簡體   English   中英

在DLL導入中找不到入口點

[英]Entry point not found on DLL import

嘗試使用C#中的第三方本機DLL,但出現了一個例外,即找不到DLL入口點,我也不知道原因是什么。

dumpbin /exports給我以下符號: ?Foo@@YA_NPBDII0II_NMEEE01PAE@Z 我用返回的undname解決了這個問題: bool __cdecl Foo(char const *,unsigned int,unsigned int,char const *,unsigned int,unsigned int,bool,float,unsigned char,unsigned char, unsigned char,char const *,bool,unsigned char*)

因此,我試圖導入這樣的功能:

[DllImport("FooDll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] // evtl. __thiscall?, Charset?
    private static extern bool Foo(string name, uint x, uint y, string app, uint width, uint height, bool switch, double factor,
        byte r1, byte g1, byte b1, string store, bool switchBack, [In, Out] byte[] result);

我還嘗試了CallingConvention = CallingConvention.ThisCall並且沒有charset參數,但是發生了相同的異常。

知道在哪里看嗎?

多虧了Wiktor和Hans的幫助,才解決了入口點問題:

必須指定一個入口點作為帶有亂碼/修飾名稱的DllImport屬性的參數,因為似乎DLL不使用extern C聲明。 此外, factor參數的類型必須為floatSystem.Single )以匹配堆棧上預期的參數長度。 因此,C#代碼現在看起來像這樣:

[DllImport("FooDll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi, EntryPoint = "?Foo@@YA_NPBDII0II_NMEEE01PAE@Z")]
private static extern bool Foo(string name, uint x, uint y, string app, uint width, uint height, bool switch, float factor,
    byte r1, byte g1, byte b1, string store, bool switchBack, [In, Out] byte[] result);

暫無
暫無

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

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