Quantcast
Channel: Visual Studio Integrate forum
Viewing all articles
Browse latest Browse all 4410

EnvDTE.ProjectItem.Delete() always throws when debugging

$
0
0

Am I doing something wrong, or is there a way around this problem ?

using System.Runtime.InteropServices;using EnvDTE;using EnvDTE100;using EnvDTE80;namespace Codyflex.VisualStudioAutomation
{publicclass VsTest
  {publicstaticvoid Test()
    {
      OleMessageFilter.Register(); // See: http://msdn.microsoft.com/en-us/library/ms228772.aspxtry {
        DTE2    dte2 = (DTE2) Marshal.GetActiveObject("VisualStudio.DTE.10.0");
        Solution4  solution = (Solution4) dte2.Solution;
        Project   project = solution.Item(@"TestTarget\TestTarget.csproj");
        ProjectItem item = project.ProjectItems.Item("Class1.cs");

        item.Delete();

        // When run in debug mode, item.Delete() always throws// COMException "The item 'Class1.cs' cannot be deleted."//// Works OK if run without debugging.
      }finally {
        OleMessageFilter.Revoke();
      }
    }
  }
}

Regards

FrankG

 

 


Viewing all articles
Browse latest Browse all 4410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>