Visual Studio 2017 change language of current file? - c#

I have a *.cs.bak file that I want to temporarily (= no permanent settings) treat as C# in Visual Studio 2017.
I only found out that Visual Studio Code can do it, but looking to do the same in visual studio yielded no results, so I ask the internet about it.

You can just add it in your project with the add existing item. Inside VS just click on your csproj and select Add -> Existing item and select your .bak.
After that, If you click on the file in Solution Explorer and look at the Properties window, you'll see a property called "Build Action". This defines whether the file will be treated like code ("Compile"), included as a resource ("Embedded Resource"), ignored ("None")...

Related

How to stop Visual Studio 2022 to add namespace automatically after copy codes from other place

As the title said, now I have a problem when copy codes from anywhere, and when pasting to my source files (C#/.cs), it will add a namespace automatically, sometimes the namespace is wrong but I don't know because it was added as unused namespace, but it will have a problem later when I build the project (with Unity) because it can't find the namespace, Then I have to delete it, it is very annoying.
I believe this is referring to the setting Tools -> Options -> Text Editor -> C# -> Advanced -> Add missing using directives on paste.
Try disabling the 'Enable namespace update when moving files' option.
In Visual Studio 2022 access the setting via the menu by following...
Tools > Options > Projects and Solutions > General

Visual Studio will automatically make functional changes to the following projects in order to open them

I decompiled a EXE and now when I try to open it. I get
One-way upgrade
Visual Studio will automatically make functional changes to the following projects in order to open them. You will not be able to open these projects in the version of Visual Studio in which they were originally created.
If I click okay I get ~250 errors
I found that need to open .csproj file and delete lines with
ProjectMode, TargetOfficeVersion, FileUpgradeFlags, UpgradeBackupLocation or OldToolsVersion. But I don't have in .csproj any lines like this.
Is there a way to fix this. Or at least a way to find what Version of Visual Studio was using the author ?

VSIX Project Context Menu

I'm trying to create a Visual Studio 2017 extension, just for fun and to learn how VS extensibility works.
My extension must be usable from the Solution Explorer tab as a context menu button, but I would like to include it at a menu level that isn't root.
My goal is to put it in the "Add" sub-menu, but at the moment I'm only able to put it at root level (when you right-click the Project item, the menu entry is shown as the last of the context menu control).
How can I move it under the "Add" node?
Can it be done from the CommandPlacement tags I have configured in my .vsct file?
Use as parent of your command the IDG_VS_CTXT_PROJECT_ADD_ITEMS group id. If you are using CommandPlacement it would be:
<CommandPlacement guid="..." id="..." priority="0x0001" >
<Parent guid="guidSHLMainMenu" id="IDG_VS_CTXT_PROJECT_ADD_ITEMS"/>
</CommandPlacement>
Remember:
The parent of a group can be another group, a menu, a toolbar, a context menu, etc. either created by your extension or an existing one of VS, identified by prefix "IDM_". See GUIDs and IDs of Visual Studio menus and GUIDs and IDs of Visual Studio toolbars.
The parent of a command is always a group, never a menu, context menu or toolbar. The group can be new (created by your extension) or an existing group of Visual Studio, identified by prefix "IDG_". You have some built-in Visual Studio groups in the links above, but for a more exhaustive list install the ExtensionTools extension (Mads Kristensen) that provides intellisense in the .vsct file or check the source code of its VsctBuiltInCache.cs file.
I think and hope this might help, though it is a general answer and not a specific one. Learn by example.
I also hope the WiX authors won't mind, but I believe the source for their Visual Studio integration component "WiX Votive" is here: https://github.com/wixtoolset/VisualStudioExtension.
There is also this: https://github.com/wixtoolset/VisualStudio.wixext. I am not sure what this is to be honest. I should, but I don't. Mr.Arnson - I summon theee (WiX developer - The Matrix's got you).
WiX Votive - VS Integration is part of the overall WiX Toolset - which is a Windows Installer deployment solution capable of compiling MSI files from XML markup. MSI files are the binary deployment files used by Windows Installer for deployment on Windows.
If of interest you 1) download and install WiX itself (currently 3.11.1), and 2) download and install the correct Visual Studio integration (the marketplace links underneath the main download) making sure you get the correct version for your Visual Studio version - of course. Both downloads from the same link (or use the Visual Studio marketplace).
Here are some further details: WiX quick-overview.

Visual Studio 2015 project fails adding to source control

i'm trying to use the functionality of the visual studio 2015 to create a project template.
I have a simple wcf-project with my special web.config. To use classes from another project i referenced it.
Those two projects are in the same solution and inherited in source control.
when i create the template and try to add a new project to the same solution, choose my custom template, the solution gets checked out but the files doens't get added to source control.
The source control says, that the binding is invalid. I dont know why.
Does anyone have any suggestions?
Thanks in advance!
Visual studio 2015 - Solution Explorer, Click Show all files,Check new file show in project tree. Right click on file select add to Project. New file need to add .sln (Project solution file) to show in project.
The project template gets added to project tree, but there no "+" sign in front of the file icons. and the solution file is checked out but no changes are made.

How to find cause of Visual Studio settings editor exceptions?

I have a project for which I can't open the settings editor in Visual Studio 2015. If I double-click the Settings.settings file or select the Settings tab in the project properties, the pane doesn't show the usual editor; just the message "The method or operation is not implemented.".
How can I go about finding the cause? Is there some way to see more details of the exception to help figure out what is not implemented? I last worked on the project in VS2013; could opening it in VS2015 have changed something to cause this?
If I create a new project and overwrite its Settings.settings file with mine, it opens fine in that project, but won't open in my existing project.

Categories