0

该项目是使用 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,文化=中性,PublicKeyToken=cc7b13ffcd2ddd51'或其依赖项之一. 该系统找不到指定的文件。

错误:510 LOG:DisplayName = System.Text.Json,Version=4.0.1.1,Culture=neutral,PublicKeyToken=cc7b13ffcd2ddd51(完全指定) LOG:Appbase = file:///C:/Program Files (x86)/AmiBroker_New_6 .0/ LOG:初始 PrivatePath = NULL 调用程序集:(未知)。Err:510 LOG:此绑定在默认加载上下文中启动。LOG:未找到应用程序配置文件。LOG:使用主机配置文件: LOG:使用来自 C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config 的机器配置文件。日志:后策略参考:System.Text.Json,版本=4.0.1.1,文化=中性,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 file:///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>
4

1 回答 1

0

无法在 Visual Studio 2019 社区版 16.7.2 中使用外部应用程序调试 c# dll 项目

如果只是想通过一个VS在debug进程下只用外部程序进入断点,由于VS无法通过外部程序加载pdb文件,所以无法做到。并且Start without Debugging不会加载 pdb 文件,因此它可以正常工作。

作为一个建议

您必须同时启动一个新的 vs 实例以通过附加到进程来调试项目。

使用第二个建议将实现它。

1) 首先,你应该检查你的额外程序:</p>

在此处输入图像描述

启动外部程序是您的完整路径,命令Amibroker.exe参数包含 VS 中当前项目 amibroker 插件的名称。

然后,取消选中Tools --> Options --> Debugging --> General下的 Enable Just My Code选项。

2)其次,记得Debugger.Launch();在你的cs文件的Main函数下添加如下:

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

            //add any code here

        }

3)第三,单击Start Debugging然后打开Debug --> Windows --> Modules然后搜索任何 dll Amibroker,然后右键单击它们-> Always Load Automatically

4)第四bin,停止Debug进程,然后删除obj文件夹。之后,再次点击Start Debugging,稍等片刻,就可以看到Choose the Just-In-Time Debugger窗口。您应该选择VS2019 IDE,它会使用当前项目启动一个新的 vs 实例attach into process。有了它,你可以单步进入断点调试代码。

在此处输入图像描述

或者您可以尝试我的第二个建议来自动启动该过程。

注意:第二个建议将通过Attach to Process与您的 amibroker 插件项目同时创建一个新的 VS 实例。

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

此外,如果您仍然遇到同样的问题,请尝试在Extensions菜单-> Manage Extensions下禁用任何第三方扩展程序,以检查是否有问题引起。

此外,通过工具->选项-->导入和导出设置->重置所有设置重置所有 VS 设置,然后禁用选项“仅启用我的代码”选项

此外,还有一个类似的问题

于 2020-09-01T10:18:34.283 回答