internal static extern int CreateAssemblyEnum( out IAssemblyEnum ppEnum, IntPtr pUnkReserved, IAssemblyName pName, AssemblyCacheFlags flags, IntPtr pvReserved);
internal static extern int GetCachePath(AssemblyCacheFlags cacheFlags, StringBuilder cachePath, ref int pcchPath);
internal static extern int CreateAssemblyEnum( out IAssemblyEnum ppEnum, IntPtr pUnkReserved, IAssemblyName pName, AssemblyCacheFlags flags, IntPtr pvReserved);
public extern static void GetCachePath([In] AssemblyCacheFlags dwCacheFlags, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder pwzCachePath, [In] ref uint pcchPath);
static extern void CreateAssemblyEnum(out IAssemblyEnum pEnum, IntPtr pUnkReserved, IAssemblyName pName, AssemblyCacheFlags dwFlags, IntPtr pvReserved);
internal static IEnumerable<string> GetGacPaths() { if (_gacPaths != null) return _gacPaths; List<string> gacPaths = new List<string>(); AssemblyCacheFlags[] flags = new AssemblyCacheFlags[] { AssemblyCacheFlags.ROOT, AssemblyCacheFlags.ROOT_EX }; foreach (AssemblyCacheFlags flag in flags) { int gacPathLength = 0; // Request the size of buffer for the path. int hresult = GetCachePath(flag, null, ref gacPathLength); // // When gacPathLength is set to 0 and passed to this method, the return value // is an error which indicates INSUFFICIENT_BUFFER, so the code here doesn't // check that return value, but just check whether the returned desired buffer // length is valid or not. // if (gacPathLength > 0) { // Allocate the right size for that buffer. StringBuilder gacPath = new StringBuilder(gacPathLength); // Get the real path string to the buffer. hresult = GetCachePath(flag, gacPath, ref gacPathLength); if (hresult >= 0) { gacPaths.Add(gacPath.ToString()); } } } if (gacPaths.Count > 0) { _gacPaths = gacPaths; } return _gacPaths; }
internal static extern int GetCachePath(AssemblyCacheFlags cacheFlags, StringBuilder cachePath, ref int pcchPath);
private static extern void GetCachePath(AssemblyCacheFlags dwCacheFlags, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder pwzCachePath, ref uint pcchPath);