I have been working with a Visual Studio Addin project for a while. The purpose of this addin is to tell me which Store Procedures are used where in my many projects.
I achive this by loading all my projects including The Business and DataAccess projects into one solution and then using EnvDTE to traverse the projects of the solution to get the specific codeitems.
This way I can Identify the methods calling the various Stored Procedures, and it works just great.
Then to identify which methods are calling the various methods in my DataAccess project, I use reflection to load the Assembly for each project :
foreach (EnvDTE.Project proj in this._solution.Projects) {
assembly = System.Reflection.Assembly.LoadFrom(GetAssemblyPath(proj));
}
private string GetAssemblyPath(EnvDTE.Project vsProject)
{
string assemblyPath = "";
string fullPath = vsProject.Properties.Item("FullPath").Value.ToString();
string outputPath = vsProject.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputPath").Value.ToString();
string outputDir = System.IO.Path.Combine(fullPath, outputPath);
string outputFileName = vsProject.Properties.Item("OutputFileName").Value.ToString();
assemblyPath = System.IO.Path.Combine(outputDir, outputFileName);
return assemblyPath;
}
This system works just great for most projects, but now I have ran into a problem, and I can’t get around it ….
Is it possible to use this sort of reflection assembly loading for a WebSite project. It fails on:
vsProject.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputPath")
Since the WebSite does not have an output path the same way as dll og WinForms projects has…
I need to use reflection since it is not possible to identify calls to overloaded methods using EvnDTE on its own. With reflection I can get the instructions of a method body thereby identifying which overloaded method is being called.
EnvDTE works fine in WebSite projects, but reflection unfortunaltely does not. 🙁
By using EnvDTE I am only able to get the text content of a method.
Does anyone know what to do to get this working?
It was failing because a WebSite project does not create an output assembly dll that is accessible and contains all info. This is instead created on the fly by the webserver.
I could not get around it and my solution was to simply convert my WebSite projects to WebApplication projects.
These are actual normal projects and have a precompiled Assembly dll that I can access.
Thanks for your comments…