Hi List,

I am encountering interesting security problems with my VB.NET application.
I have an MDI form that instantiates a utility object for things like
program load, message passing, etc. The MDI form uses
System.Reflection.Assembly.LoadFrom() to dynamically load an assembly off a
server. This is connected to the utility object and calls various methods
on it. I get an error thrown when the loaded assembly calls a method on the
utility object that reads the registry (i.e. does a GetSettings). Here's
the error's .ToString:

"System.Security.SecurityException: Request for the permission of type
System.Security.Permissions.RegistryPermission, mscorlib,
Version=1.0.3300.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 Microsoft.VisualBasic.Interaction.GetSetting(String AppName, String
Section, String Key, String Default)
   at SCAT.SCATComm.MRUListGet(String ListName) in
C:\VBDotNet\SCATComm\SCATComm.vb:line 626"

The bottom line (SCAT.SCATComm.MRUListGet) is my method to get the registry
setting. The line of code that throws the exception is:

ListSetting = GetSetting("SCAT", "MRU", ListName)

ListSetting is a string.

The code works when I do a project reference to the assembly in question,
but fails when it is dynamically loaded.

Any ideas on how to make it work?

Regards,

Jay Ayliff
Stalis Ltd

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to