【发布时间】:2017-03-30 14:44:20
【问题描述】:
考虑以下代码:
private static void Main(string[] args)
{
var exe = new MemoryStream(File.ReadAllBytes(args[0]));
var assembly = AssemblyLoadContext.Default.LoadFromStream(exe);
assembly.EntryPoint.Invoke(null, new object[] { new string[0] });
}
此程序在 .net core 1.1 应用程序中编译,args 在其调试输出目录中包含 .net core 中通用 hello world 的 dll 的路径。
当我运行这个程序时,它会从内存中的 dll 副本加载程序集,然后调用入口点。 Visual Studio 似乎成功识别出这个 dll 与我在解决方案中打开的 hello world 项目相同,我可以单步调试并调试这个调用的程序。
当我从程序集的内存副本加载时,VS 调试器如何知道在哪里找到源代码?
【问题讨论】:
-
完全一样,您可以从调试文件夹中的 exe 运行应用程序,然后转到 Visual Studio 并“附加到进程”,然后进行调试。这是因为您是从 Debug 文件夹运行的。
标签: c# .net visual-studio debugging .net-assembly