繁体   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