diff -r ace2c5fc4b7f -r 76f859f4aea1 Hardware/PInvokeDelegateFactory.cs --- a/Hardware/PInvokeDelegateFactory.cs Sun Oct 21 14:45:24 2012 +0000 +++ b/Hardware/PInvokeDelegateFactory.cs Sat Oct 27 11:40:28 2012 +0000 @@ -4,7 +4,7 @@ License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - Copyright (C) 2009-2010 Michael Möller + Copyright (C) 2009-2012 Michael Möller */ @@ -13,6 +13,7 @@ using System.Reflection; using System.Reflection.Emit; using System.Runtime.InteropServices; +using OpenHardwareMonitor.Collections; namespace OpenHardwareMonitor.Hardware { @@ -24,18 +25,20 @@ AssemblyBuilderAccess.Run).DefineDynamicModule( "PInvokeDelegateFactoryInternalModule"); - private static readonly IDictionary wrapperTypes = - new Dictionary(); + private static readonly IDictionary, Type> wrapperTypes = + new Dictionary, Type>(); public static void CreateDelegate(DllImportAttribute dllImportAttribute, out T newDelegate) where T : class { Type wrapperType; - wrapperTypes.TryGetValue(dllImportAttribute, out wrapperType); + Pair key = + new Pair(dllImportAttribute, typeof(T)); + wrapperTypes.TryGetValue(key, out wrapperType); if (wrapperType == null) { wrapperType = CreateWrapperType(typeof(T), dllImportAttribute); - wrapperTypes.Add(dllImportAttribute, wrapperType); + wrapperTypes.Add(key, wrapperType); } newDelegate = Delegate.CreateDelegate(typeof(T), wrapperType,