See the question and my original answer on StackOverflow

You can have it work without any code change if you add something like this in your app.config (adapt versions and paths to your context)

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly> 
            <assemblyIdentity name="Microsoft.Win32.Registry" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /><codeBase version="4.1.1.0"
                href="C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.win32.registry\4.5.0\lib\net461\Microsoft.Win32.Registry.dll"/>
        </dependentAssembly>
    </assemblyBinding>
</runtime>