question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Manually change Framework in runtimeconfig.json?

See original GitHub issue

Hi, I’m working on upgrading our legacy Windows app to .NET 5.

In our legacy architecture, we used to have WinForms and WPF in many assemblies. At the same time, we had a headless version of our app that was running the same assemblies but detouring the UI code in runtime. That worked well on Linux under Mono.

In .NET 5, I see that as soon as I enable WPF and/or WinForms for the project, its target Framework changes to Microsoft.WindowsDesktop.App. With this, the app cannot be run on Linux.

However, if I manually change the Framework in runtimeconfig.json to Microsoft.NETCore.App, the app loads and our detour code seems to work as it did before.

I wonder if there’s an official/supported way to implement this scenario?

Thanks!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:20 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
Alovchin91commented, Nov 16, 2021

@sfoslund Hi, sorry for the late reply. Yes, I’d say we’ve found a workaround. We have to manually patch runtimeconfig.json and deps.json to include dependency on mocked System.Windows.Forms.dll, but that should work for us for now.

Please feel free to close this issue. I’ll reopen it shall I need further assistance 🙂 Thank you!

0reactions
AraHaancommented, Jul 13, 2022

What if you needed to manually have the project use the runtimeconfig.json file manually created because the SDK incorrectly list the wrong framework last which is a problem because that runtimeconfig.json is itself part of another framework which then gets used in a project which results in the the host (fxr) to incorrectly look for hostpolicy in the wrong framework? I tried to work around it myself by adding the NETCore.App framework last manually to no success as the runtimeconfig.json file still generates with it listed first instead of last.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NET Runtime configuration settings
Learn how to configure the .NET runtime using configuration settings.
Read more >
Deep-dive into .NET Core primitives, part 3: runtimeconfig. ...
NET Core applications contain a file named <something>.runtimeconfig.json . This file can be used to control a variety of options.
Read more >
Select which .NET version to use
Learn how .NET automatically finds and chooses runtime versions for your program. Additionally, this article teaches you how to force a ...
Read more >
How to build App without App.runtimeconfig.json?
I want to keep only App.exe and App.dll in my folder, what do I have to do to get rid of that App.runtimeconfig.json...
Read more >
.NET Core Run-time Settings | Documentation
NET 5+ applications can use the "runtimeconfig.json" file, MSBuild properties and environment variables to set various run-time settings.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found