Registry Access across a network

samsmithnz

Well-known member
Joined
Jul 22, 2003
Messages
1,038
Location
Boston
I have a vb.net app that I am trying to run across the network. When the application starts it reads some registry values to get a connectionstring. The problem I am having is that it works when you run it on my desktop, and it works when you run it on the server, but when I try to run the server version from my desktop, I get this error:
Code:
"System.Security.SecurityException: Request for the permission of type System.Security.Permissions.RegistryPermission, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.
   at System.Security.CodeAccessSecurityEngine.CheckHelper(PermissionSet grantedSet, PermissionSet deniedSet, CodeAccessPermission demand, PermissionToken permToken)
   at System.Security.CodeAccessSecurityEngine.Check(PermissionToken permToken, CodeAccessPermission demand, StackCrawlMark& stackMark, Int32 checkFrames, Int32 unrestrictedOverride)
   at System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark)
   at System.Security.CodeAccessPermission.Demand()
   at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)
   at Microsoft.Win32.RegistryKey.OpenSubKey(String name)
   at ExchangeRates.modMain.ReadRegistrySettings() in C:\Projects\ExchangeRates\modMain.vb:line 87"

I dont understand why!?! Im running it on my desktop with my desktop cpu, so Id assume that its in my desktops memory and is trying to access my desktops registry - which I have permission to do.

What is happening here???

Here is my registry code
Code:
    Read in the registry settings required for the application
    Private Function ReadRegistrySettings()
        Dim objRegistryKey As Microsoft.Win32.RegistryKey
        Dim strLocation As String = "SOFTWARE\CurrencyExchange"
            
            objRegistryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(strLocation)
            
            get the connectionstring information for the SQL Server
            strConnectionString = objRegistryKey.GetValue("SQLConnString")
            objRegistryKey.Close()

    End Function
 
Last edited by a moderator:
Nevermind figured it out:

You have to set up the framework security. You can can do this in: Control Panel/Administrative Tools/Microsoft .NET Framework 1.1 Configuration
Then select Runtime Security Policy, Adjust Zone Security, Make changes to this computer, Select Local Intranet and set it to full trust, then click Next and Finish.
 
Back
Top