Search code examples
.netgac

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


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?


Solution

  • Did you try checking the Assembly.GlobalAssemblyCache property?

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

    ...or:

    bool loadedFromGac = Assembly.GetExecutingAssembly().GlobalAssemblyCache;