As I told earlier, it's a permission problem.
I can't tell you from the code you provided why you can't see the error message, but when reproducing the problem I got a clear permission error...
Server Error in '/RegistryTest' Application.
--------------------------------------------------------------------------------
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: Requested registry access is not allowed.
Source Error:
Line 8: protected void Page_Load ( object sender, EventArgs e )
Line 9: {
Line 10: RegistryKey oKey = Registry.LocalMachine.OpenSubKey( @"SOFTWARE\Michlol2000", true );
Line 11:
Line 12: DateTime oNow = Convert.ToDateTime( oKey.GetValue( "Now" ) );
Source File: c:\m2000_net\Local\Registry\Registry\Default.aspx.cs Line: 10
Stack Trace:
[SecurityException: Requested registry access is not allowed.]
System.ThrowHelper.ThrowSecurityException(ExceptionResource resource) +52
Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable) +10629081
RegistryTest.Default.Page_Load(Object sender, EventArgs e) in c:\m2000_net\Local\Registry\Registry\Default.aspx.cs:10
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
System.Web.UI.Control.OnLoad(EventArgs e) +92
System.Web.UI.Control.LoadRecursive() +54
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6704
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +245
System.Web.UI.Page.ProcessRequest() +72
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21
System.Web.UI.Page.ProcessRequest(HttpContext context) +58
ASP.default_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\registrytest\c3463957\356fb4d5\App_Web_irghuleb.0.cs:0
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +341
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18331
The reason is that when you run from VS you use your own identity, which probably has all the permissions to read and write registry...
When you run directly against iis you got the pool identity which by default is ApplicationPoolIdentity. This identity has no permissions even to read registry!!!
To resolve it you can change the pool identity to someone has permissions, LocalSystem for instance...
---
Not part of the answer but very very VERY important in my opinion.
Do not use registry if you have no an extremely good reason to do so. And never do it from an web application - web application is for the client!!! your code running on the server, which means that actions of the client will change the registry on the server!!! (that's your case!!!)
If you have configuration values to store use config file.
Regards
Peter