簡體   English   中英

如何解決“本地DLL libmbusmaster.dll丟失! 請將該DLL文件部署到與mbusmaster.net.dll相同的目錄中。”

[英]How to solve the issue of “Native DLL libmbusmaster.dll is missing! Please deploy the DLL file into the same directory as mbusmaster.net.dll.”

我在.Net中使用了FieldTalk Modbus。 當我運行應用程序時,在為MbusTcpMasterProtocol創建對象時出現錯誤。

MbusTcpMasterProtocol mbusProtocol =新的MbusTcpMasterProtocol();

錯誤是:

本機DLL libmbusmaster.dll丟失! 請將DLL文件部署到與mbusmaster.net.dll相同的目錄中。

我將libmbusmaster.dll添加為項目中的“ ExistingItem”,並將mbusmaster.net.dll添加為項目的參考。

將“ libmbusmaster.dll”添加到項目中並不會將其添加到“ mbusmaster.dll”所在的文件夾中。 您指定的mbusmater.dll位於“調試”文件夾中。 當您在項目中添加“ libmbusmaster.dll”時,它可能已添加到項目的根文件夾中(而不是在調試中)。 要將其添加到調試中,請在解決方案中轉到“ libmbusmaster.dll”的屬性,然后選擇“始終復制”或“如果更新則復制”。

mbusmaster.net.dll使用相對的dll導入[DllImport("libmbusmaster.dll")]

這意味着它將嘗試從條目程序集所在的位置而不是mbusmaster.net.dll所在的位置)加載libmbusmaster.dll

對於大多數程序,條目匯編路徑和mbusmaster.net.dll路徑將相同。 但是,如果您有一個應用程序說要從其他文件夾加載插件,並且插件使用這些程序集,則該插件將必須使用此處描述的SetDllLocation技術

暫無
暫無

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

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