change .net framework after create new project - visual-studio

I've written a program with Visual Studio 2012 and .Net Framework 4.5.
Now I want to change the .Net Framework to .Net Framework 4.
How can I change it?

Right click on the project, choose Properties.
Under "Application" you have a dropdown called TargetFramework. Change that to 4.0

Right mouse button click on project within Solution Explorer. There is TargetFramework dropdown on Application tab.

Related

Visual Studio 2019: How to edit menu

In Visual Studio versions prior to VS2019, .NET framework 4.7.2, if you wanted to design a MenuStrip, you just added the MenuStrip to the form and start typing the ToolStripMenuItems. Like this:
I've recently moved to VS2019, and started to use .NET 5. If I add a Menustrip, I get an empty strip, which seems not easy to edit (I colored the background of the main form, to clearly see the white menu strip)
My question is: how to add ToolStripMenuItems?
I see the little arrow on the right, and I can select Edit Items, but to add a menu that way is quite cumbersome.
If I open an old solution in VS2019, I can edit the menu as I used to do. So it's not VS2019.
If I create a new VS2019 project using an old .NET version, I can't edit the menu, so it's not the .NET version
If I copy paste InitializeComponents from an old project to a new .NET 5.0 VS209 solution I cannot edit the menu
So, how to edit the menu? Is edit items really the proper method to edit your menus from now on?
I believe that the MenuStrip editor experience difference comes down to .NET Core vs .NET Framework.
Edit: .NET 5 = .NET Core vNext
We covered MenuStrips while we were doing WinForms in my C# class and this exact question came up. .NET Framework solutions allow you to use the convenient editor as you have demonstrated. .NET Core solutions do not.
The easiest way I found to build out my MenuStrip items when in .NET Core was to click on the menu strip, then there is a property called "Items" which is a collection. In the properties pane, you can click the three dots button to bring up the Items Collection Editor:
Here you can create new ToolStripMenuItem objects to build your menu.
Possibly related post, others suggesting this is a Core vs Framework issue: MenuStrip not allowing to create menu
This issue has been fixed
in Visual Studio latest release v16.10: 05/25/2021 (https://learn.microsoft.com/en-us/visualstudio/releases/2019/release-notes). I have tested this both in net 5 (current) and net core 3.1 (LTS).
Demo:
https://youtu.be/3s55hWrHx4U
You might have used the option that says "Windows Forms App."
This is wrong. You should use "Windows Forms App(.NET Framework)." This will let you edit the menuStrip control the easy way.

Visual Studio Clickonce Specific Target tab missing

Following instructions in this link to deploy with Clickonce:
https://learn.microsoft.com/en-us/visualstudio/deployment/quickstart-deploy-using-clickonce-folder?view=vs-2019
I right click in the project and select Publish, and the Publish wizard opens, with the "Target" tab selected as expected, and I select "Folder" option. Then, when I click the "Next" button, it does not appear the "Specific tab", but it goes directly to "Publish location" tab. The problem with this is that I cannot select "Clickonce" anywhere because I do not see the "Specific target" tab, so there is no "Install location", "Settings", "Sign manifests" or "Configuration" tabs.
This is the expected tab that not appears:
And this is the screen I see (sorry, it is in Spanish):
It is a .NET Framework 4.8 project.
Why is Clickonce missing? What can I do to get the right screen in the wizard so I can use Clickonce?
Thank you
UPDATE: I have tried to update to .NET 5, and then magically ClickOnce appears in the Publish wizard. So, how can I use ClickOnce with net48 in a SDK scheme project? Any help?
.Net Framework ClicOnce is not compatible with the SDK style projects, here the link discussion. So the correct answer here would be: is not possible.
What you could do is either downgrade your csproj style to old version or update your project to a .net core 5 or use cli msbuild to deploy.
The "expected tab" is the update content for .NET Core & .NET 5. As you said, when you update the target framework to .NET 5, the tab will be shown.
If you are developing with .NET Framework 4.8, you still can right-click the project and click Publish. Because it will be published via ClickOnce bu default.
Or follow the steps Project => Properties => Publish.

.NET core - Publish page not showing on VS 2019 (version 16.3.4)

Since I updated Visual Studio Professional 2019 to latest version (16.3.4), I'm not able to publish my .NET Core console app to a folder anymore (I'm not using online services).
I used to right click on my executable project, click on "Publish" menu item, configure my publish profile in a dedicated window and then, of course, publish. This configuration was saved in a XML file in <myProjectFolder>\Properties\PublishProfiles\.
Now all I can see when I click on "Publish" menu item is the following empty page, from which I can do nothing, neither configure a publish profile nor actually publish.
Is there a way to fix this?

Add ATL Simple Object in Visual Studio 2017

I am working with an old ATL/COM project in Visual Studio 2017.
In previous versions of Visual Studio you could select "Add Class" and then select the option "Add simple ATL object" to add a COM class to the project. This option appears to be completely missing in Visual Studio 2017.
Has the option been moved?
Have I missed an installation option?
Does Visual Studio fail to recognize my project as an ATL project? (It was created with a much older version.)
Or is this the end of the road for ATL?
I'm not sure whether this an answer, but it is too much for a comment and more than just an edit to the question.
I have tested on two systems, with
Visual Studio Community 2017, Version 15.1
Visual Studio Professional 2017, Version 15.3.2
and I believe that the functionality has changed between these two versions. I think it is unlikely to be a difference between the Community and Professional versions.
In both cases I created a new ATL project and tried three ways to add a class:
Add class... from the context menu in the Class View
Add class... from the context menu in the Solution Explorer
Add New Item... from the context menu in the Solution Explorer
With version 15.1, Add Class opens the following dialog, from which I can add an ATL Simple Object.
With version 15.3.2, Add Class opens the following dialog, without any option for an ATL Simple Object.
However, with version 15.3.2, Add New Item opens the following dialog, with a new option to create an ATL Simple Object, which was previously not available in this dialog.
So, it seems that the functionality has been moved. Curiously, it is no longer available in the Class View (which in my opinion is a mistake).
This problem is caused by changes in the project template and code wizard in version 15.3 of Visual Studio 2017.
The operation procedure has changed between version 15.2 or earlier and version 15.3 or later.
The blog article that explained this change is as follows.
Changes to Project Templates and Code Wizards in 15.3
Although it is described as an item in the release notes, there are few people who are watching, and details on how the actual is going on is unknown.
Visual Studio 2017 version 15.3 Release Notes
C++ Language Services
Project and Code Wizard
•We have rewritten several project and code wizards in the signature dialogue style.
•Add Class launches the Add Class wizard directly. All of the other items that were previously here are available under "Add > New Item".
•Win32 projects are under the Windows Desktop category in the New Project dialog.
•The Windows Console and Desktop Application templates now create the projects without displaying a wizard. There's a new Windows Desktop Wizard under the same category that displays the same options as before.
My experience with Visual Studio 2015 version 15.9.2 is that I had to uncheck Security Development Lifecycle (SDL) checks when I added an ATL Project, otherwise when I add the Simple ATL Object I get a messagebox with the error "did not find a .idl file in project name of my project".

How to detect the language version of Visualstudio?

I need to detect the language version of VS and do some action depending on it. How to detect it?
Thanks
I think you want to use DTE.LocaleID, that's what other add-ins use to find their resource DLLs.
Here is the example of how to detect default C# language version in Visual Studio 2019:
With a mouse, select the required project and right click then in opened window select Properties.
In opened Properties Window Select vertical Build tab and click on Advanced button.
In the opened Advanced Build Settings window it is the row - Language version. In the example: Automatically selected based on framework version.
If the information which framework version corresponds default C# language version, is required the link (Why can't I select a different C# version? - C# language versioning) can be opened. In this page are the rules on how according to the target framework is determined default C# language version and information on how the default C# language version can be changed.
Which framework version the project uses are in the project settings file. In the example image framework version is .NET Core 3.0 version, so the default C# language version is 8.00.

Resources