0

I have a self-written .NET Framework 4.6.2 application (call it Player) dynamically loading self-written .NET Core 2.0 DLLs (call them Game-DLLs). Now I would like to enable creators of .NET Core 2.0 Game DLLs to debug into their code. To do this, the .NET Framework 4.6.2 Player application needs to be started with the "Managed (v4.6, v4.5, v4.0) code" Debugger attached. I can do this manually: Start the Player.exe and choose Debug->Attach from VS's menu, select the correct debugger and it works: I can debug into the .NET Core Game DLL.

Visual Studio IDE (v2017) seems to store debug configurations for .NET Core projects in some very new thus very undocumented "launchSettings.json" file. I managed to specify a launchSetting profile to start the Player.exe but I did not find a way to attach the correct debugger. It turns out that starting the debugger with a launchSetting profile will always choose the "Managed (CoreCLR)" debugger. This starts the exe but debugging is disabled because no symbols are loaded and thus breakpoints do not work.

There is very few documentation about the options in launchSettings.json and the little you can find is all about developing ASP.Net.

Does anybodyknow how to specify the debugger in launchSettings.json OR know a good source of documentation for launchSettings.json?

Thank you!

Additional information:

DLLs that reference the .NET 2.0 standard are INDEED compatible and usable among different flavors of .NET, including .NET Core 2.0, .NET Framework 4.6.2, latest Xamarin, and others. As I mentioned above: This already works and is out of question. I can take a DLL written with .NET Core 2.0 and thus obeying to the .NET Standard 2.0 and load it - dynamically with Assembly.LoadFrom or statically referenced - from an executable running on .NET Framework 4.6.2. This works like a charm.

The only thing is: If I want to debug into the .NET Core DLL in this case, I have to manually setup the debugger. I don't understand why Visual Studio 2017 replaced the very elaborate debugger-setup-project-page by some fast-hack with only the ASP.Net use-case in mind.

The funny thing is: I can even setup Visual Studio Code (in its very well documented "launch.json" file) to use the correct debugger and debug the scenario I described with a single click on the green Play button.

Unfortunately the launchSettings.json-schema is not of much use, I already stepped over it. It lists (somehow) the known Attributes but leaves no clue how they are interpreted or what Values are allowed. For example I suspected the sdkVersion Attribute to somehow help me set the .NET Framework 4.2... Debugger, but it says nothing about what this Attribute is good for neither how to specify some sdk...

Chris M
  • 73
  • 7
  • You talk about .Net Core, but you also tagged the question with .Net Standard. So which is it? – svick Oct 07 '17 at 01:49
  • .NET Framework 4.6.2 projects cannot load .NET Core 2.0 assemblies, as they are not compatible. Do you mean .NET Standard 2.0? https://blog.lextudio.com/which-class-library-project-to-go-in-visual-studio-2015-2017-a48710cf3dff – Lex Li Oct 07 '17 at 02:20
  • @LexLi https://learn.microsoft.com/en-us/dotnet/standard/net-standard -- .NET Framework v4.6.1+ (w/ .NET Core 2.0 SDK) is compatible with .NET Core 2.0 – Svek Oct 07 '17 at 03:31
  • @Svek did you really read every words of that article? The table is for .NET Standard compatibility and does not indicate ".NET Framework x.x is compatible with .NET Core x.x". – Lex Li Oct 07 '17 at 03:51
  • @LexLi - Just to be clear, (1) my correction was to your comment **"they are not compatible"** -- they are, in the sense that they share the same .NET API. (2) Can you load a `netcoreapp2.0` assembly in a `net461`? No. As you stated it should be `netstandard2.0` since either .NET Core or .NET Framework will have access to totally different libraries beyond the shared .NET API – Svek Oct 07 '17 at 04:30
  • @Svek if you personally would like to understand compatibility in that way, I have no more to comment. – Lex Li Oct 07 '17 at 05:01
  • The schema for launchSettings.json [is here](https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/launchsettings.json). Nothing that resembles an option to configure the debug engine to be used. This was a temporary hack used by the asp.net team, they spearheaded the .netcore project and had to make up a lot of their own tooling to get going. How this is supposed to evolve is unclear, could be the debugging team making their debug engine capable of detecting the CLR flavor. As-is, it is too early to jump on this band-wagon. – Hans Passant Oct 07 '17 at 07:09
  • Thanks for all your answers. I commented them under "additional information" in my original question. – Chris M Oct 07 '17 at 09:52
  • "I can take a DLL written with .NET Core 2.0 and thus obeying to the .NET Standard 2.0" That's not how it works. An assembly can target .Net Core 2.0 or .Net Standard 2.0. If you target .Net Core 2.0, then it's not a .Net Standard assembly and there is no reason to expect you could load it into a .Net Framework application. – svick Oct 08 '17 at 12:41
  • As I said: it works. No need to discuss whether I can expect it to work. It works! I created a .NET Core 2.0 DLL (using the "dotnet new classlib" command) and I can very well load it into a .Net Framework 4.6.2 app. That's the whole point why there is somthing like .Net Standard 2.0 in the first place (which is NOT another flavor of some .Net implementation but a STANDARD). Watching Immo Landwerth on the .Net Deep Dive helped me a lot to understand this.(https://channel9.msdn.com/Shows/On-NET/NET-Standard-Deep-Dive?term=.NET%20Standard%20Deep%20Dive) – Chris M Oct 08 '17 at 16:40
  • This Microsoft document mentioned launsettings.json: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/environments And this blog introduce the launsettings.json in .NET Core 1.0, hope that could help you: https://exceptionnotfound.net/working-with-environments-and-launch-settings-in-asp-net-core/ If possible, please share your solution structure to help us know how your solution works and help us reproduce this issue. – Weiwei Oct 09 '17 at 09:01

0 Answers0