문제

I have a shared class which calls the following registry key which is used by a Windows Service and also an ASP MVC3 website:

irsalKey = Registry.LocalMachine
                    .CreateSubKey("SOFTWARE")
                    .CreateSubKey("MyApp");

On my local (Win7 32bit) PC this works as expected.

On my test 2008 server, the Service read/writes the "Wow6432" node, but website does not? My guess is that the service is 32bit (uses 32 bit binaries) but the website is 64bit under IIS?

What can I do so that both read/write the same keys? It doesn't matter WHICH key this is, but it needs to be the same for both!

Thx

도움이 되었습니까?

해결책 2

Googling pointed me to use the following:

RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32)

It IS in MSDN, but the documentation wasn't too clear (to me anyway!) but this forces any RegistryKey to use it's 32bit version.

다른 팁

You could try explicitly compiling the website for x86 instead of AnyCPU - that might force it to 32 bit mode. (set up a new platform in the Build/Configuration Manager menu)

You'd also have to turn on the app pool option in IIS to enable 32 bit applications (advanced settings on the app pool).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top