Simon Dugré
Simon Dugré

Reputation: 18946

Retrieve Assembly currently which use another Assembly

I'm trying to get the assembly of a "currently using by" assembly and I can't figure out how I can do this. I were able to do it when it is referenced in a Form App, but it's is not working when used in a Web Service.

To get it from a WinForm, I used : Assembly.GetCallingAssembly() which return my CallingApp's dll well and then have access to his Assembly. But when it is use for a Web Service, it return the Current DLL itself instead of Web Service's one.

Anyone know how I can resolve this?

Edit #1

More precisely : MyWebService reference MyDLL. In MyDLL, I want to get the MyWebService or any other Project Assemblies which use MyDLL. That why I use Assembly.GetCallingAssembly() which work perfectly for a Win Form app... but not with a Web Service.

Upvotes: 0

Views: 209

Answers (1)

OnoSendai
OnoSendai

Reputation: 3970

I can imagine two different approaches:

Via StackTrace you may have to iterate through each frame in order to determine the assembly.

This thread may give you some hints:

C# - Get calling method's Assembly?

Upvotes: 1

Related Questions