Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating Projects Dynamically
    text
    copied!<p>I want create dynamically projects in my solution</p> <p><strong>C# Code</strong></p> <pre><code>protected void Page_Load(object sender, EventArgs e) { string projectPath = @"C:\Users\lucas_000\Documents\Visual Studio 2010\Projects\ModelingProject1\ModelingProject1\ModelingProject1.modelproj"; using (IModelingProjectReader projectReader = ModelingProject.LoadReadOnly(projectPath)) { IModelStore store = projectReader.Store; foreach (IClass umlClass in store.AllInstances&lt;IClass&gt;()) { try { Engine engine = new Engine(); //engine.BinPath = RuntimeEnvironment.GetRuntimeDirectory(); Project project = engine.CreateNewProject(); project.AddNewImport(@"$(MSBuildBinPath)\Microsoft.CSharp.targets", null); BuildPropertyGroup props = project.AddNewPropertyGroup(false); props.AddNewProperty("AssemblyName", "myassembly"); props.AddNewProperty("OutputType", "Library"); BuildItemGroup items = project.AddNewItemGroup(); items.AddNewItem("Reference", "Some.Assembly"); items.AddNewItem("Compile", "somefile.cs"); project.Save("myproject.csproj"); } catch (Exception e2) { } } } } </code></pre> <p><strong>Problem</strong></p> <p>When will Save the project, occurs the <code>UnauthorizedAccessException</code> in a folder that I don't want Save this new project there. </p> <p>How can I create this project in my current Solution in Visual Studio 2010 ?</p> <p><strong>UPDATE</strong></p> <p>The Line <code>project.Save("myproject.csproj")</code> tries to save in <code>C:\Program Files\Common Files\Microsoft Shared\DevServer\10.0\myproject.csproj</code></p> <p>All my solution are in <code>C:\Users\lucas_000\Documents\Visual Studio 2010\Projects</code></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload