簡體   English   中英

無法在 Visual Studio 2019 社區版 16.7.2 中使用外部應用程序調試 c# dll 項目

[英]Unable to debug c# dll project with an external app in Visual Studio 2019 Community edition 16.7.2

該項目是使用 kriasoft 的 amibroker .NET SDK 用 C# 開發的“amibroker 插件”。

我已經“構建”了我的插件,當我在“控制台項目”中測試它時它工作正常。 但是當我嘗試使用外部應用程序 (Amibroker.exe) 調試它時,visual studio 突然關閉,並在幾秒鍾內啟動一個空白的 Visual Studio 窗口,其中包含一個“附加”選項,而不是我們通常看到的“開始”運行我們的項目。

我點擊了附加選項並附加到我的 amibroker 應用程序,它成功顯示了“Debug.Writeline()”消息。 但是我的斷點都沒有被擊中。 我的代碼在任何窗口中都不可見,就像我調試控制台應用程序時一樣。

在谷歌研究后,我發現外部應用程序應該由visual studio自動啟動,並且應該在我的斷點處停止。 在我的情況下不會發生這種情況。 我搜索了很多,甚至更新了整個vs2019,但沒有任何進展。

如果有人可以幫助我,那就太好了。

注意:“開始而不調試”工作正常。

關於“無法加載文件或程序集“System.Text.Json”的新信息:無法加載文件或程序集“System.Text.Json,版本=4.0.1.1,Culture=neutral,PublicKeyToken=cc7b13ffcd2ddd51”或其依賴項之一. 該系統找不到指定的文件。

Err:510 LOG: DisplayName = System.Text.Json, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 (Fully-specified) LOG: Appbase = file:///C:/Program Files (x86)/AmiBroker_New_6 .0/ 日志:初始 PrivatePath = NULL 調用程序集:(未知)。 錯誤:510 日志:此綁定在默認加載上下文中啟動。 日志:未找到應用程序配置文件。 LOG:使用主機配置文件: LOG:使用來自 C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\config\\machine.config 的機器配置文件。 日志:后政策參考:System.Text.Json,版本=4.0.1.1,Culture=neutral,PublicKeyToken=cc7b13ffcd2ddd51 日志:正在嘗試下載新的 URL 文件:///C:/Program Files (x86)/AmiBroker_New_6.0 /System.Text.Json.DLL。 日志:正在嘗試下載新的 URL 文件:///C:/Program Files (x86)/AmiBroker_New_6.0/System.Text.Json/System.Text.Json.DLL。 日志:正在嘗試下載新的 URL 文件:///C:/Program Files (x86)/AmiBroker_New_6.0/System.Text.Json.EXE。 日志:正在嘗試下載新的 URL 文件:///C:/Program Files (x86)/AmiBroker_New_6.0/System.Text.Json/System.Text.Json.EXE。

我的packages.config條目:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="CsvTextFieldParser" version="1.2.1" targetFramework="net461" />
  <package id="Microsoft.Bcl.AsyncInterfaces" version="1.1.0" targetFramework="net461" />
  <package id="System.Buffers" version="4.5.1" targetFramework="net461" />
  <package id="System.Memory" version="4.5.4" targetFramework="net461" />
  <package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net461" />
  <package id="System.Runtime.CompilerServices.Unsafe" version="4.7.1" targetFramework="net461" />
  <package id="System.Text.Encodings.Web" version="4.7.1" targetFramework="net461" />
  <package id="System.Text.Json" version="4.7.1" targetFramework="net461" />
  <package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net461" />
  <package id="System.ValueTuple" version="4.5.0" targetFramework="net461" />
  <package id="UnmanagedExports" version="1.2.7" targetFramework="net461" />
</packages>

應用程序配置文件

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <probing privatePath="ghyiouys\;Plugins\;plugins;"/>
            <dependentAssembly>
                <assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1" />
                <codeBase version="4.0.1.1" href="Plugins/System.Text.Json.dll"/>
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
                <codeBase version="4.1.4.0" href="Plugins/System.Numerics.Vectors.dll"/>
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
            </dependentAssembly>
            <dependentAssembly>
                <assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
</configuration>

無法在 Visual Studio 2019 社區版 16.7.2 中使用外部應用程序調試 c# dll 項目

如果你只是想通過一個VS調試過程下的外部程序單步進入斷點,是無法做到的,因為VS無法通過外部程序加載pdb文件。 並且Start without Debugging不會加載 pdb 文件,因此它運行良好。

作為建議

您必須另外啟動一個新的 vs 實例來同時通過attach to process調試項目。

使用第二個建議將實現它。

1) 首先,你應該檢查你的額外程序:

在此處輸入圖片說明

啟動外部程序是您的Amibroker.exe的完整路徑,命令行參數包含您在 VS 中當前項目的 amibroker 插件的名稱。

然后,取消選中工具-->選項-->調試-->常規下的啟用僅我的代碼選項

2) 其次,記得添加Debugger.Launch(); 在您的 cs 文件中的 Main 函數下,如下所示:

 static void Main(string[] args)
        {
            Debugger.Launch();

            //add any code here

        }

3) 第三,單擊Start Debugging ,然后打開調試--> Windows -->模塊,然后搜索有關Amibroker任何 dll,然后右鍵單擊它們-->始終自動加載

4) 第四,停止Debug進程,然后刪除binobj文件夾。 之后,再次單擊Start Debugging ,稍等片刻,您將看到有關Choose the Just-In-Time Debugger窗口的窗口。 您應該選擇VS2019 IDE ,它會通過attach into process使用當前項目啟動一個新的 vs 實例。 有了它,你就可以進入斷點調試代碼。

在此處輸入圖片說明

或者您可以嘗試我的第二個建議以自動啟動該過程。

注意:第二個建議將通過附加到進程與您的 amibroker 插件項目同時創建一個新的 VS 實例。

============================================

此外,如果您仍然遇到同樣的問題,請嘗試在“擴展”菜單-->“管理擴展”下禁用任何第三方擴展,以檢查是否有問題導致。

此外,通過工具->選項->導入和導出設置->重置所有設置重置所有 VS 設置,然后禁用選項啟用僅我的代碼選項

此外,還有一個類似的問題

暫無
暫無

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

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