tags:

views:

72

answers:

2

Given a class library DLL that can be installed on the GAC (production) or not (development), I need to know whether the executing assembly is running from the GAC or not. How can I know this?

+7  A: 

Did you try checking the Assembly.GlobalAssemblyCache property?

bool loadedFromGac = this.GetType().Assembly.GlobalAssemblyCache;

...or:

bool loadedFromGac = Assembly.GetExecutingAssembly().GlobalAssemblyCache;
Fredrik Mörk
+2  A: 

Use the AssembyInfo class to find out the loaded assemblies for your app. The returned Assembly objects have a property called GlobalAssemblyCache which indicates what you need.

MSDN Docs for Assembly

Robert Massa