After upgrading Fax.NET project to .NET 4 Client Profile i got this Exception:
MissingMethodException:
Constructor on type 'Microsoft.Win32.SafeHandles.SafeRegistryHandle' not found.
Exception occurred on return statement of this function:
private static SafeHandle CreateRegistrySafeHandle(IntPtr handle)
{
Type type;
type = typeof(SafeHandle).Assembly.GetType("Microsoft.Win32.SafeHandles.SafeRegistryHandle");
return (SafeHandle)Activator.CreateInstance(
type,
BindingFlags.Instance | BindingFlags.NonPublic,
null,
new object[] { handle, true },
null);
}
What is solution for this exception?
The SafeRegistryHandle Constructor is public ( BindingFlags.Public ) since .NET 4, not internal or private ( BindingFlags.NonPublic ).
If you have access to the source code, you can replace the method with
private static SafeHandle CreateRegistrySafeHandle(IntPtr handle)
{
return new SafeRegistryHandle(handle, true);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.