简体   繁体   English

如何调试不是主C#应用程序依赖的类库(在Visual Studio中)?

[英]How to debug a class library that is not a dependency of the main C# application (in Visual Studio)?

I have a solution where I load some dlls at runtime with Assembly.LoadFile. 我有一个解决方案,我在运行时使用Assembly.LoadFile加载一些dll。 Because these dlls can come from multiple sources at any time, I cannot add them as a dependency to the main application. 因为这些dll可以随时来自多个源,所以我不能将它们作为依赖项添加到主应用程序中。 It seems that Visual Studio won't load pdb files for dlls that are not marked as a dependency. 似乎Visual Studio不会为未标记为依赖项的dll加载pdb文件。

I don't want to add each dll I'm debugging to the dependencies just to debug them. 我不想将我正在调试的每个dll添加到依赖项中,只是为了调试它们。 Is there a way to manually load symbols for these external dlls? 有没有办法为这些外部dll手动加载符号?

You should set the (plugin) assembly as startup project and in the properties screen at the Debug tab, you can change the start action . 您应该将(插件)程序集设置为启动项目,并在“调试”选项卡的属性屏幕中,您可以更改启动操作 Change it to "Start external program" and select the main project assembly(exe). 将其更改为“启动外部程序”并选择主项目程序集(exe)。

When you copied the output of the plugin to the main projects output by hand, you have to change the output path in the Build tab, so the plugin comes in the right path to be loaded by the main program. 当您手动将插件的输出复制到主项目输出时,您必须在“构建”选项卡中更改输出路径,因此插件将出现在主程序加载的正确路径中。

Use reflection. 使用反射。 Use methods without creating objects. 使用方法而不创建对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM