EmbeddedDude
EmbeddedDude

Reputation: 251

C# debugging in Immediate Window in Visual Studio 2022 only works for old .net frameworks, but not .Net 5.0

I am working on Visual Studio 2022, building a c# .net class library which used .net framework 4.8.x, but now I have to convert that assembly to .NET 6.0.

I heavily use "immediate window" on VS while programming which works great when working with the older .net 4.8.x framework, but as soon as I switch to another duplicate solution that uses .NET CORE (1.0 ~ 6.0, I tried all), it pops up error that "A project with an Output Type or Class Library cannot be started directly". To fix that, I had to add a dummy/empty executable project to be able to use the immediate window again. Did Microsoft change immediate window functionality during design time for .NET Core?

It is VERY frustrating that just to upgrade to .NET Core, I am now having to overly complicate our build setup while it works perfectly fine on .net framework 4.8.x. Does anyone know a work around so that I can get rid of the dummy executable project I had to add as the startup project to our solution? Now every time I use immediate window, it adds quite a bit of extra time to build empty UI of the dummy project which is very frustrating as I have absolutely no use for it. Please help if you know more details on this topic. I searched for this issue on Google but very little is showing up - all I see is Microsoft saying "we fixed it in latest Visual Studio" or "we cannot investigate any further", etc... none of which helped.

See https://learn.microsoft.com/en-us/visualstudio/debugger/debugging-dll-projects?view=vs-2022 under "Use the Immediate window" for debugging a DLL without a calling app.

Upvotes: 0

Views: 391

Answers (1)

Kit
Kit

Reputation: 21729

A good workaround is to switch your tooling altogether.

LINQPad provides a rich execution environment, acting as a calling executable.

It supports your own .NET, .NET Core, and .NET Framework assemblies.

And—this is in no way meant to be snarky—unit tests are a great approach in that they provide lasting value beyond a single debugging scenario.

Upvotes: 0

Related Questions