Reputation: 2056
Here is the requirement: I want to create a custom visual studio C# project template, via which the created project has all references added correctly to pass compilation.
I got the problem that some references will be missing in this case: if the generated project contains code calling method MethodA
of type AClass
in a DLL named A.dll
, but one of AClass.MethodA
's parameter is defined in B.dll
.
In short, A.dll
references B.dll
on method MethodA
in class AClass
, compilation will failed because of B.dll
is missing.
Anyone know the perfect solution on how to find the dependency of B.dll
for compiling purpose?
I tried Assembly.GetReferencedAssemblies
but it will get all the referenced assemblies in which most of them are unnecessary.
I also tried to use ReflectionResolve
event, but it won't help too.
Upvotes: 0
Views: 272
Reputation: 2347
Resharper handles this smooth as silk. A missing reference causes it to display an error in the source code window and it even suggests the correct dll to reference.
Resharper also has an API, if you want to code it yourself
Upvotes: 1
Reputation: 16287
Using Redgate .Net Reflector might be a good choice. Though it is not free, but you can have a trial version for some days.
Click Analyze toolbar button, it will give you all the dll/assembly dependencies.
Upvotes: 0