1

I have an application, a solution with multiple projects, including one database project. The application was built in .NET 4.5 Core. All the C# code projects in it were later migrated to .NET 6. I've been able to build it and deploy it, and it runs correctly on the server. I use Visual Studio 2022 on Windows 10.

I just switched to a new development laptop. The first time I loaded the solution in Visual Studio on it, was presented with this:

Dialog box reading "The SQL Server project ZZZ targets .NET Framework 4.5, which is no longer supported. While you can change your target framework at any time, for stability and security we recommend that you move to the most recent supported release. Choices: Update the target to .NET Framework 4.8 (Recommended); Download .NET Framework 4.5 targeting pack (opens in browser); Do not load this project

In upgrading to .NET 6, I ran a global replacement to update the version in all the .csproj files, but I hadn't thought to look at the .sqlproj file from the database project. Indeed, it still showed 4.5: <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>. What I wondered was why the dialog didn't give me an option to update to 6.0.

I chose the 4.8 option. The TargetFrameworkVersion in the .sqlproj file changed to 4.7.2 (not 4.8). In addition, a new, empty element was added to the same PropertyGroup: <TargetFrameworkProfile />. The I had to reload the database project, which in Solution Explorer had been annotated by the word "unloaded" in parentheses after it. The solution did then build.

However, it still wasn't .NET 6. I thought I'd see what happened if I just changed it to v6.0. What happened is that the project became unloaded from the solution again. I reloaded it. A dialog appeared, similar to the previous one, except this time the second option was "Download the .NET Framework 6.0 targeting pack (opens in browser)". The first option was still the one marked "Recommended".

I chose the 6.0 option. In my default browser (Chrome), the URL https://www.bing.com/?ref=go&linkid=prd=12485&pver=12&sbp=TargetPackMissing&os=0&over=&plcid=0x409&olcid=0&clcid=&ar=&sar=&o1=.NETFramework,Version=v6.0&o2=&o3=&o4=&o5= was loaded. What appeared was the Bing home page! Huh?

Turning back to Visual Studio, I noticed that the project remained marked "(unloaded)".

So many questions:

  • Given that this never came up on my old laptop, why did Visual Studio decide to have problems with the application on the new laptop?
  • What is a "targeting pack"? I have .NET 6; is this something in addition to that that a SQL database project requires?
  • Why is it referring to .NET Framework 6 when there's no such thing as .NET Framework 6?
  • Why is 4.8 "preferred" when my application is in 6? Is it really preferred or is this an error?
  • If it claims to be upgrading to 4.8, why does the project file say afterwards that the target framework is 4.7.2?
  • Why is it sending me to the Bing home page? Where is it supposed to be sending me?
  • How do I fix this and get the database project on the right version of .NET?

UPDATE: Adding a screenshot of the second dialog for the person who doubted what the second option says. enter image description here

Green Grasso Holm
  • 468
  • 1
  • 4
  • 18
  • There is no something like .NET 4.5 Core. There is an old .NET Framework (3.5, 4.0 and newer up to 4.8) and a new framework .NET Core (1, 2, 3), and then .NET Core has been renamed to simple .NET and versions: 5, 6, 7, and upcoming 8. – Lukasz Szczygielek Mar 29 '23 at 22:28

1 Answers1

-1

Given that this never came up on my old laptop, why did Visual Studio decide to have problems with the application on the new laptop?

Its a new laptop. Maybe you don't have the same versions of .NET installed. Maybe its a different version of Visual Studio installed.

What is a "targeting pack"? I have .NET 6; is this something in addition to that that a SQL database project requires?

It is a pack for installing a .Net version on your computer.

Why is it referring to .NET Framework 6 when there's no such thing as .NET Framework 6?

I doubt it is doing this. You are probably confused about what you are seeing.

Why is 4.8 "preferred" when my application is in 6? Is it really preferred or is this an error?

4.8 is preferred over 4.5 because 4.5 is out of support and 4.8 is not.

If it claims to be upgrading to 4.8, why does the project file say afterwards that the target framework is 4.7.2?

This is strange but if you have successfully upgraded from 4.5 to 4.7.2 then call it a win.

Why is it sending me to the Bing home page? Where is it supposed to be sending me?

The link you provided is a link to Bing. Use it to search for things (like "How to Install .Net 4.8")

How do I fix this and get the database project on the right version of .NET?

There is no right version of .NET (only better or worse choices given your particular situation - and usually out of support version are not ideal).

In general, your questions seem to suggest you aren't aware of the major difference there is between .Net Framework and .Net Core (aka .Net). .Net Framework 4.5 is out of support, hence the recommendation to upgrade to 4.8 (which is sensible). It is not sensible to just go straight from 4.5 to .Net 6 - you should first analyze the project for compatibility and follow MS recommendations for migrating from .NET framework to .Net Core (a useful middle step is to first migrate from .Net framework to .Net standard).

Whatever you do, you should make sure you have the .net development pack installed for the version you are using. I would try to get it working on the current version if possible - you are starting your project on a new laptop, so first, just try to get it to build and run, before you start all kinds of upgrade activities. But in this case, you may have problems because 4.5 isn't supported and I don't think you can so easily find it now. You may succeed however in upgrading to 4.7.2 (be sure you have installed 4.7.2 on your pc).

Helpful links:

porting from .net framework to .net core

upgrade-assistant-overview

topsail
  • 2,186
  • 3
  • 17
  • 17
  • If the new laptop didn't have .NET 6 installed, I wouldn't be able to build the application, which, as I noted in the end, I can do. As I can with the other .NET 6 applications I'm developing. Also, yhy are you doubting that the dialog _of which I posted a screen capture_ says what it says? Why are you supposing that I'm confused when I repeated what you can plainly see for yourself that it says? – Green Grasso Holm Mar 29 '23 at 23:14
  • The dialog of which you posted a screen shot has absolutely no reference whatever to `.Net Framework 6` - which also doesn't exist which is why I doubt you saw such a thing in an dialog box from Visual Studio. Just saying! Having .Net 6 installed is not necessarily the solution to your problem here. – topsail Mar 29 '23 at 23:59
  • I've pasted the second dialog to the bottom of my post. So there's that. The bottom line is that I want to keep the data project up to date so that it isn't based on a version of .NET or .NET Framework or .NET Core or whatever that goes obsolete. – Green Grasso Holm Mar 30 '23 at 09:12
  • OK, you're right, I was confused. I went into Git and found that the C# projects were all "netcoreapp3.1". But the data project was "TargetFrameworkVersion" 4.5, as I said. And Framework 4.7.2 continues to be supported. I apologize. Nevertheless, when it told me the option was to upgrade to 4.8, why did it _actually_ upgrade to only 4.7.2? – Green Grasso Holm Mar 30 '23 at 09:24
  • 1
    These are all mysteries. Honestly I don't know. My guess is the dialog box text is simply wrong (or somehow very misleading). MS changes its "branding" a lot. Maybe even their own devs get confused. Also not sure why it didn't upgrade to 4.8 but you can finish the job by upgrading from 4.7.2 to 4.8. For example see this post: https://stackoverflow.com/questions/54912949/how-to-upgrade-net-framework-4-6-2-to-4-7. We also had an app at my job everyone said was .Net core 3.1 but it targeted 4.7.2 -- so at the end of the day it was a framework app. – topsail Mar 30 '23 at 12:36
  • 1
    As far as keeping your app on a version that doesn't go obsolete, I predict 4.8.x to be supported for a long time (years? a decade?). See [here](https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-framework) for the fine print. For Net Core versions they have published life cycles that should be kept in mind. For example. Net 6 is supported until Nov 2024. See [here](https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core) for more fine print. – topsail Mar 30 '23 at 12:44
  • Thanks. I found 4.8.1 was available in the project's Properties and was able to upgrade to that and rebuild with no trouble. – Green Grasso Holm Mar 30 '23 at 13:54