locked
Not able to get path of master page template in visual studio 2010(C#) RRS feed

  • General discussion

  • hi,

       i am using this code to get path of master page template.

       

    EnvDTE.Solution soln = System.Activator.CreateInstance(Type.GetTypeFromProgID("VisualStudio.Solution.10.0")) as EnvDTE.Solution;

    MessageFilter.Register();

    soln.DTE.MainWindow.Visible = true;

    EnvDTE80.Solution2 soln2 = soln as EnvDTE80.Solution2;

    string csTemplatePath1 = soln2.GetProjectTemplate("ClassLibrary.zip", "CSharp");          string csTemplatePath = soln2.GetProjectTemplate("ConsoleApplication.zip", "CSharp"); string wcfTemplatePath = soln2.GetProjectTemplate("WAPService.zip", "CSharp");

    string csTemplatePath2=soln2.GetProjectTemplate("EmptyWebApplicationProject40.zip",CSharp);

    stringTemplateMasterpage = soln2.GetProjectItemTemplate("MasterPage.zip", "CSharp");

    -------------------------------------------------------------------------------

    i am able to get project template path of classlibrary,consoleapplication,wapservice,emptywebapplictionproject40.

    but problem is that i am not able to get path of master page template using this line

    stringTemplateMasterpage = soln2.GetProjectItemTemplate("MasterPage.zip", "CSharp");  i am getting exception that filenotfoundexception.

    i have checked that file is alredy exists at location

    C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplatesCache\CSharp\Web\1033\MasterPage.zip

                                   i am getting this error.

    System.IO.FileNotFoundException was caught

      Message=The system cannot find the file specified. (Exception from HRESULT: 0x80070002)

      Source=""

      StackTrace:

           at EnvDTE80.Solution2.GetProjectItemTemplate(String TemplateName, String Language)

           at CodeGenerationTool.CodeGenerator.btn_SoltionCreate_Click(Object sender, EventArgs e) in C:\Users\trainee11\Desktop\CodeGenerationTool\CodeGenerationTool\CodeGenerator.cs:line 3249

      InnerException:

    what sholud i do??where i am going wrong?plz experts help me out





    • Edited by ShailiShah Friday, April 6, 2012 11:55 AM
    Friday, April 6, 2012 11:28 AM