Hi,
so, I tested accessing the registry from an asp.net app and everything works
fine, this is what I did:
-I created a webapp called testwebapp
-added a button and a label
-the handler for the button is:
LabelTest.Text =
Registry.LocalMachine.OpenSubKey("SOFTWARE\\mykey").GetValue("myvalue").ToSt
ring();
-I created the registry key and value
-I load the webapp, click the button, and the content is shown, as expected.
-now, I use regedt32, I change the permissions on the key so ASPNET is
DENIED read and full control to the key
-now, I click on the button, and as expected, the following is shown:
Server Error in '/testwebapp' 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 50: private void Button1_Click(object sender, System.EventArgs e)
Line 51: {
Line 52: LabelTest.Text =
Registry.LocalMachine.OpenSubKey("SOFTWARE\\mykey").GetValue("myvalue").ToSt
ring();
Line 53:
Line 54: }
Source File: webform1.aspx.cs Line: 52
Stack Trace:
[SecurityException: Requested registry access is not allowed.]
Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)
+440
Microsoft.Win32.RegistryKey.OpenSubKey(String name) +27
testwebapp.WebForm1.Button1_Click(Object sender, EventArgs e) in
webform1.aspx.cs:52
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
stBackEvent(String eventArgument) +58
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +2075
System.Web.UI.Page.ProcessRequest() +218
System.Web.UI.Page.ProcessRequest(HttpContext context) +18
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication+IExecutionSte
p.Execute() +179
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously) +87
----------------------------------------------------------------------------
----
I don't know, maybe you can post the exact code you're using so we can try
to see if that has something to do with the
problem you're experiencing.
bye!