Search code examples
wpfwinformsvisual-studio-2010projectsolution

how visualstudio knows about the type of current project?


In Visual Studio, the context menu command for adding an element in a WinForms project is different by the one showed for a WPF project. In fact, I can see "Add->Windows Form" in the first and "Add->Window" in the second. By which parameter/configuration VisualStudio can differentiate which kind of project is currently opened? My first bet was the .csproj file but I can see nothing distinctive about the project type.


Solution

  • There is often a ProjectTypeGuids element in the project file that allows Visual Studio to determine what project type it is. It's also stated in the solution file, referencing the project.

    <ProjectTypeGuids>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    

    as an example.

    Here's a somewhat old link to a list of project guids, but most are still valid: http://onlinecoder.blogspot.se/2009/09/visual-studio-projects-project-type.html

    And here's a blogpost, outlining what it's all about:

    http://www.dzimchuk.net/blog/post/ProjectTypeGuids-node-in-VS-project-files.aspx

    "On a regular class library project the ‘ProjectTypeGuids’ node was missing at all. It didn’t take long to find what those mysterious GUID’s are about: List of known project type Guids. So the first one says it’s a WPF project and the second one says it’s a C# project."