Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I add certain file types to VS2010 projects?

Tags:

I'm trying to add a WPF ResourceDictionary to a C# project that was created a while ago. The project was not originally a WPF project, but now I need to include some WPF resources in it.

When I right click the project and select "Add", ResourceDictionary is not an option. Even if I open the Modal dialog box and navigate to where the ResourceDictionary type should be (along side the other WPF types), it is not present.

Also, when I manually add a XAML file that has ResourceDictionary syntax to the project, I can't programmatically load it using WPF Application.Load(uri) syntax, so I feel VS2010 is preventing me from adding the file for a reason.

How can I make my project "able" to have a ResourceDictionary added without recreating the entire project from scratch as a WPF project and re-adding every file from scratch?

Additionally, what defines the file types that can be added to projects so I can avoid similar problems in the future? Hopefully it's something simple like a line I need to add to my AssemblyInfo.cs file.

like image 370
Michael Avatar asked Apr 04 '11 20:04

Michael


People also ask

How do I add files to Clickonce deployment?

With a project selected in Solution Explorer, on the Project menu, click Properties. Click the Publish tab. Click the Application Files button to open the Application Files dialog box. In the Application Files dialog box, select the Group field for a file that you wish to include in the new group.

How do I add a file to AC project?

You can add existing files to your project by right-clicking on the Project node and selecting Add > Add Files.... Alternatively, to add an entire folder, select Add > Add Existing Folder.... The file browser is shown. It lets you search your system for the required item to add.

How do you add a file to a project in VS code?

Drag a folder to the File Explorer to add it to the current workspace. You can even select and drag multiple folders. Note: Dropping a single folder into the editor region of VS Code will still open the folder in single folder mode.

Are Visual Studio 2022 solutions backwards compatible?

You can install and use Visual Studio 2022 alongside previous versions of Visual Studio, including Visual Studio 2019, Visual Studio 2017, Visual Studio 2015, Visual Studio 2013, and Visual Studio 2012.


1 Answers

Close the project. Create a new project that is of the type of WPF project you would have used. Then open the new .csproj file in notepad. Find the ProjectTypeGuids element. Copy those GUIDs to clipboard. Open your existing .csproj file in notepad. Append those GUIDs into this file's ProjectTypeGuids element. (Check for dupes.) Reload your project in Visual Studio. You should be able to add all the WPF file types now.

PS: I haven't done this with WPF specifically, but I have with other project types and it has worked without issue.

I believe the GUIDS are the same for everyone so the values you need should be: {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ... this should save you the step of creating a new project.

like image 54
Jim Bolla Avatar answered Oct 15 '22 07:10

Jim Bolla