我有一個.net核心2.0控制檯應用程序,將執行以下操作(簡化):調試代碼在.NET芯動態加載組件2.0
var a = Assembly.Load(Assembly.GetEntryAssembly()
.GetReferencedAssemblies()
.First(i => i.Name == "MyAssembly"));
var t = a.GetType("MyType");
var i = (MyBaseType)Activator.CreateInstance(t);
i.Execute();
當我通過代碼調試它stepps成MyType.Execute()
如預期。
但是如果我加載與下面的代碼的程序集:
var path = new FileInfo(Assembly.GetExecutingAssembly().Location);
var a = Assembly.LoadFile(Path.Combine(path.DirectoryName, "MyAssembly.dll"));
的代碼仍然有效,但我不能踏進MyType.Execute()
同時調試。
任何想法爲什麼/有什麼問題?
也許只是我的代碼選項應該被禁用? https://blogs.msdn.microsoft.com/zainnab/2010/10/25/understanding-just-my-code/ – Alexan
您需要確保.pdb文件與您正在加載的dll位於相同的位置。然後Visual Studio將加載該數據,並允許它停在斷點處。 – codeSetter