B
BasmaWed
Guest
Hi,
I have this method that returns the active project:
namespace Utils
{
internal static class LocalUtils
{
internal static EnvDTE.DTE dte => CoreUtility.ServiceProvider.GetService(typeof(DTE)) as EnvDTE.DTE;
internal static VSProjectNode GetActiveProject()
{
Array projects = LocalUtils.dte.ActiveSolutionProjects as Array;
if (projects?.Length > 0)
{
Project project = projects.GetValue(0) as Project;
return project?.Object as VSProjectNode;
}
return null;
}
But I get NullReferenceException in this line:
internal static EnvDTE.DTE dte => CoreUtility.ServiceProvider.GetService(typeof(DTE)) as EnvDTE.DTE;
Continue reading...
I have this method that returns the active project:
namespace Utils
{
internal static class LocalUtils
{
internal static EnvDTE.DTE dte => CoreUtility.ServiceProvider.GetService(typeof(DTE)) as EnvDTE.DTE;
internal static VSProjectNode GetActiveProject()
{
Array projects = LocalUtils.dte.ActiveSolutionProjects as Array;
if (projects?.Length > 0)
{
Project project = projects.GetValue(0) as Project;
return project?.Object as VSProjectNode;
}
return null;
}
But I get NullReferenceException in this line:
internal static EnvDTE.DTE dte => CoreUtility.ServiceProvider.GetService(typeof(DTE)) as EnvDTE.DTE;
Continue reading...