I created an application that generates WCF, creates a visual studio instance and generates the solution automatically.
Visual Studio 2012 works perfectly, the problem is when visual studio is installed in its 2015 version.
If I put breakpoints everywhere, it generates everything correctly, but if I start it without interruption points it starts to burst and it is not always at the same point.
Throw the error:
"The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER))"
and I do not know how to solve it.
I leave you a piece of code. It is usually burst in the for, moments where the application does not give time to finish another thread.
bool exe = false;
if (pathnametlb.ToUpper().Contains(".EXE"))
exe = true;
System.Type type = null;
//Visual Studio 2015
if (type == null)
type = System.Type.GetTypeFromProgID("VisualStudio.DTE.14.0");
////visual studio 2013
//if (type == null)
//type = System.Type.GetTypeFromProgID("VisualStudio.DTE.12.0");
//visual studio 2012
//if (type == null)
// type = System.Type.GetTypeFromProgID("VisualStudio.DTE.11.0");
////visual studio 2014
//if (type == null)
// type = System.Type.GetTypeFromProgID("VisualStudio.DTE.13.0");
Object obj = System.Activator.CreateInstance(type, true);
string nametlb = Path.GetFileNameWithoutExtension(pathnametlb);
string pathInicial = Path.GetDirectoryName(pathnametlb);
EnvDTE80.DTE2 dte8Obj = (EnvDTE80.DTE2)obj;
Solution4 solucion = (Solution4)dte8Obj.Solution;
string nombresolucion = nametlb + "Service";
string nombreProyecto = nametlb + "WCF";
string newPrjectproxy = nombreProyecto + "Proxy";
string csTemplatePath = "";
bool existefuente = false;
string sln = "";
try
{
sln = pathInicial + @"\" + nombresolucion + @"\" + nombresolucion + ".sln";
//Entra para modificar el sln con rutas Relativas
Integration.ReemplazarRutasProyectos(sln);
solucion.Open(sln);
existefuente = true;
}
catch (Exception ex)
{
solucion.Create(pathInicial + @"\" + nombresolucion, nombresolucion);
csTemplatePath = solucion.GetProjectTemplate("ClassLibrary.zip", "CSharp");
solucion.AddFromTemplate(csTemplatePath, pathInicial + @"\" + nombresolucion + @"\" + nombreProyecto, nombreProyecto, false);
// solucion.SaveAs(nombreProyecto);
solucion.SaveAs(nombresolucion);
}
//System.Threading.Thread.Sleep(7000);
//VSLangProj.VSProject vsPrj = (VSLangProj.VSProject)dte8Obj.Solution.Projects.Item(1).Object;
VSLangProj.VSProjectItem vsPrjItem;
var proyecto = dte8Obj.Solution.Projects.Item(1).ProjectItems.Item(1).Object;
vsPrjItem = (VSLangProj.VSProjectItem)proyecto;
VSLangProj.VSProject prjActual = null;
foreach (Project item in dte8Obj.Solution.Projects)
{
VSLangProj.VSProject prj = (VSLangProj.VSProject)item.Object;
if (prj != null)
{
if (prj.Project.Name.Equals(nombreProyecto))
{
prjActual = prj;
}
}
}