I added some Class by C# Code DOM at run time. and I built my project programmatically like what you see:
Microsoft.Build.Evaluation.Project p = new Microsoft.Build.Evaluation.Project();
if (ProjectCollection.GlobalProjectCollection.GetLoadedProjects(@"D:\imanSal\SmlpeApp\SmlpeApp\SmlpeApp.csproj").Count == 0)
{
p = new Microsoft.Build.Evaluation.Project(@"D:\imanSal\SmlpeApp\SmlpeApp\SmlpeApp.csproj");
}
else
{
p = ProjectCollection.GlobalProjectCollection.GetLoadedProjects(@"D:\imanSal\SmlpeApp\SmlpeApp\SmlpeApp.csproj").First();
}
File.Delete(outputFileName + ClassName + ".cs");
p.RemoveItem(BuildProj.GetProjectItem(p, outputFileName + this.ClassName + ".cs"));
p.Save();
p.Build();
And its perfectly working much. And it will build my project successfully BUT!. I need to reload my project and run it again for knowing my new class (which I created it in run time by CodeDOM)! So, what's your solution? How can I circumvent this problem?. I want to create my class in run time and use it without any need to reloading project.
i use this classes as my model entities in Entity framework Code first
Aucun commentaire:
Enregistrer un commentaire