title: How do I programmatically refresh/reload a VS project after modifying the underlying file?
body: <p>I am developing a Visual Studio package and I have written some code that will make a file in Solution Explorer dependant upon another file.</p>
  
  <p>What this means is that it gives them the same relationship as code-behind files or designer files, where they appear nested under the parent file with a plus/minus icon.</p>
  
  <pre><code>+ MainForm.cs
  
  
  - MainForm.cs
     MainForm.Designer.cs
     MainForm.resx
  </code></pre>
  
  <p>The code that I have written successfully and correctly modifies the underlying project file, however the change is not reflected in Solution Explorer until the project is closed and re-opened.</p>
  
  <p>I'm looking for some code that will refresh or reload the project so that the change is visible in Solution Explorer immediately.</p>
  
  <p>Further Information...</p>
  
  <p>Here is the sudo code that demonstrates the mechanism by which I create the dependant file.</p>
  
  <pre><code>IVsBuildPropertyStorage vsBuildPropertyStorage = GetBuildPropertyStorage();
  vsBuildPropertyStorage.SetItemAttribute(projectItemIdentifier, "DependentUpon", parentFileName);
  </code></pre>
  
  <p>I have also tried adding this in an attempt to get the project to reload, but it doesn't have any effect.</p>
  
  <pre><code>project.Save();
  VSProject obj = project.Object as VSProject;
  obj.Refresh();
  </code></pre>