static Utils() { var sysroot = Environment.GetFolderPath(Environment.SpecialFolder.Windows); var f40 = Path.Combine(sysroot, "Microsoft.NET", Environment.Is64BitProcess ? "Framework64" : "Framework", "v4.0.30319", "fusion.dll"); var f20 = Path.Combine(sysroot, "Microsoft.NET", Environment.Is64BitProcess ? "Framework64" : "Framework", "v2.0.50727", "fusion.dll"); if (File.Exists(f40)) { var f40dll = LoadLibrary(f40); if (f40dll != IntPtr.Zero) { Net40Fusion = new UnmanagedLibrary(f40dll); CreateAssemblyEnum40 = (CreateAssemblyEnumDelegate)Marshal.GetDelegateForFunctionPointer(Net40Fusion.GetProcAddr("CreateAssemblyEnum"), typeof (CreateAssemblyEnumDelegate)); CreateAssemblyNameObject40 = (CreateAssemblyNameObjectDelegate)Marshal.GetDelegateForFunctionPointer(Net40Fusion.GetProcAddr("CreateAssemblyNameObject"), typeof (CreateAssemblyNameObjectDelegate)); CreateAssemblyCache40 = (CreateAssemblyCacheDelegate)Marshal.GetDelegateForFunctionPointer(Net40Fusion.GetProcAddr("CreateAssemblyCache"), typeof (CreateAssemblyCacheDelegate)); CreateInstallReferenceEnum40 = (CreateInstallReferenceEnumDelegate)Marshal.GetDelegateForFunctionPointer(Net40Fusion.GetProcAddr("CreateInstallReferenceEnum"), typeof (CreateInstallReferenceEnumDelegate)); } } if (File.Exists(f20)) { var f20dll = LoadLibrary(f20); if (f20dll != IntPtr.Zero) { Net20Fusion = new UnmanagedLibrary(f20dll); CreateAssemblyEnum20 = (CreateAssemblyEnumDelegate)Marshal.GetDelegateForFunctionPointer(Net20Fusion.GetProcAddr("CreateAssemblyEnum"), typeof (CreateAssemblyEnumDelegate)); CreateAssemblyNameObject20 = (CreateAssemblyNameObjectDelegate)Marshal.GetDelegateForFunctionPointer(Net20Fusion.GetProcAddr("CreateAssemblyNameObject"), typeof (CreateAssemblyNameObjectDelegate)); CreateAssemblyCache20 = (CreateAssemblyCacheDelegate)Marshal.GetDelegateForFunctionPointer(Net20Fusion.GetProcAddr("CreateAssemblyCache"), typeof (CreateAssemblyCacheDelegate)); CreateInstallReferenceEnum20 = (CreateInstallReferenceEnumDelegate)Marshal.GetDelegateForFunctionPointer(Net20Fusion.GetProcAddr("CreateInstallReferenceEnum"), typeof (CreateInstallReferenceEnumDelegate)); } } }