How to know whether I'm running from the GAC or not?

.net, gac

Solution

Did you try checking the `Assembly.GlobalAssemblyCache` property?

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

...or:

bool loadedFromGac = Assembly.GetExecutingAssembly().GlobalAssemblyCache;

Problem

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?

Original source