问题描述
该项目是使用kriasoft的amibroker .NET SDK在C#中开发的“ amibroker插件”。
我有“构建”我的插件,当我在“控制台项目”中对其进行测试时,它可以正常工作。但是,当我尝试使用外部应用程序(Amibroker.exe)对其进行调试时,Visual Studio突然关闭,并在几秒钟后启动了一个空白的Visual Studio窗口,并带有“附加”选项来代替我们通常看到的“开始”运行我们的项目。
我单击了附加选项并附加到了我的amibroker应用程序,它成功显示了“ Debug.Writeline()”消息。但是我的断点都没有命中。我的代码在任何窗口中都不可见,就像在调试控制台应用程序时通常那样。
根据Google的研究,我发现外部应用程序应该由Visual Studio自动启动,并且应该在我的断点处停止。就我而言,这没有发生。我搜索了很多东西甚至更新了整个vs2019,但没有任何进展。
如果有人能帮助我,那将是很棒的事情。
注意:“无需调试即可启动”。
有关“无法加载文件或程序集'System.Text.Json”的新信息: 无法加载文件或程序集'System.Text.Json,版本= 4.0.1.1,区域性=中性,PublicKeyToken = cc7b13ffcd2ddd51'或其依赖项之一。系统找不到指定的文件。
错误:510日志:displayName = System.Text.Json,版本= 4.0.1.1, 文化=中性,PublicKeyToken = cc7b13ffcd2ddd51(完全指定) 日志:Appbase = file:/// C:/程序文件(x86)/Amibroker_New_6.0/日志: 初始PrivatePath = NULL调用程序集:(未知)。错误:510日志: 此绑定在默认的加载上下文中启动。日志:无申请 找到配置文件。日志:使用主机配置文件:日志: 使用机器配置文件从 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文件:/// 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>
app.config
<?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中使用外部应用程序调试c#dll项目 2019社区版16.7.2
如果您只想通过一个VS在调试过程中与外部程序一起进入断点,则无法完成此操作,因为VS无法通过外部程序加载pdb文件。并且无需调试就可以启动不会加载pdb文件,因此效果很好。
作为建议,
您还必须另外启动一个新的vs实例,以同时通过附加到进程调试项目。
使用第二个建议将会实现。
1)首先,您应该检查自己的额外程序:
启动外部程序是Amibroker.exe
的完整路径,命令行参数包含VS中当前项目amibroker插件的名称。
然后,取消选中工具-> 选项-> 调试下的启用我的代码选项-> 常规。
2)其次,请记住在CS文件的Main函数下添加Debugger.Launch();
,如下所示:
static void Main(string[] args)
{
Debugger.Launch();
//add any code here
}
3)第三,单击Start Debugging
,然后打开 Debug -> Windows -> 模块,然后搜索有关Amibroker
的所有dll,然后右键单击它们-> 始终自动加载。
4)第四,停止调试过程,然后删除bin
和obj
文件夹。之后,再次单击开始调试,等待一会儿,您将看到有关选择即时调试器窗口的窗口。您应该选择 VS2019 IDE ,它会通过attach into process
与当前项目启动一个新的vs实例。有了它,您可以进入断点来调试代码。
或者您可以尝试我的第二条建议以自动开始该过程。
注意:第二个建议将同时与您的amibroker插件项目附加到处理来创建新的VS实例。
=========================================
此外,如果仍然遇到相同的问题,请尝试在扩展菜单-> 管理扩展下禁用任何第三方扩展检查是否有导致它的原因。
也,通过工具-> 选项-> 导入重置所有VS设置和导出设置-> 重置所有设置,然后禁用选项启用我的代码选项。