Get the Name of the Assembly Containing the Selected Project Item in Visual Studio
By Michael Detras
In Visual Studio extensibility, you may need to get various properties of a Visual Studio project. One of this is the assembly name.
Assuming you have a DTE or DTE2 type applicationObject, you can get the name of the assembly containing the currently selected item by using the following code:
SelectedItem selectedItem = applicationObject.SelectedItems.Item(1);
ProjectItem projectItem = selectedItem.ProjectItem;
string assemblyName = null;
for (int i = 1; i <=projectItem.ContainingProject.Properties.Count; i++)
{
Property property = projectItem.ContainingProject.Properties.Item(i);
if (property.Name == "AssemblyName")
assemblyName = property.Value.ToString();
}
Get the Name of the Assembly Containing the Selected Project Item in Visual Studio (950 Views)