RE: Assembly loaded from URL needs to read registry - but can't

From: Jan Petras (JanPetras_at_discussions.microsoft.com)
Date: 02/25/05


Date: Thu, 24 Feb 2005 22:39:03 -0800

What I would do is that I would modify enterprise policy on the server to
indicate that any code comming from \\yourserver\yourdirectorywithdlls\* is
FullTrust. Then, don't worry about creating evidence and all that. Or, sign
the assemblies with your public key and modify enterprise policy that any
assembly signed with code with that public key is of "Full Trust" level...

Generally, play around with caspol.exe (or MMC snapin) to get what you need.
There may be other solutions as well, I would try this first.

Regards,
JnP76

"gkelly" wrote:

> I have a set of applications that use a common assembly library.
>
> AppA, AppB and AppC all use LibA and LibB
>
> These will run on about 25 computers.
>
> AppA and LibA need to read registry to determine database connect string to
> use and other misc config stuff
>
> For a while anyway, all code will be updated periodically. So, I decided
> place code on our web server.
>
> Instead of AppA and AppB being "Windows Applications" I changed them to
> Class Libraries.
>
> I created a Launcher App that will use Assembly.LoadFrom to load from a url
> like http://server/applib/AppA.dll
>
> However, since code loaded this way runs in a different context I get an
> error error such as:
>
> Request for the permission of type
> System.Security.Permissions.RegistryPermission failed..
>
> I have read about this and somewhat understand the issues involved.
>
> Question: Is there a "simple" way to load a dll from a URL and have it run
> with the same permission as code that was
> loaded locally?
>
> I thought the following would work, but it doesnt. Same error happens. So,
> obviously my understanding is very limited.
>
> Evidence ev = new Evidence();
> ev.Merge( AppDomain.CurrentDomain.Evidence );
> ev.AddHost( new Zone( SecurityZone.MyComputer ));
> Assembly v_assembly = Assembly.LoadFrom( "http://server/applib/AppA.dll",
> ev );
>
> when creating an object instance from this assembly it still can't read the
> registry. I "thought" this would load the assembly so that's
> it's code would run with same permissions as the launcher. It doesn't.
>
> Any help would be appreciated.
>
> gkelly
>
>
>



Relevant Pages

  • Re: Problems with CAS and remote objects
    ... >Request for the permission of type System.Security.Permissions.SecurityPermission ... >There is a server called Server1. ... >The Program.exe that is running on DT1 receives the security exception. ... >All assemblies are stronly named. ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: Code Permission - Should I write a custom "Friend Permission" (or
    ... If you can consider your server to be safe from direct meddling, ... need to worry about a client directly disabling CAS on your server. ... BTW, on the side issue of authoring a custom permission, it's not generally ... declaring the permission attribute from the local policy assemblies list. ...
    (microsoft.public.dotnet.framework)
  • Re: Long delay before Drives & Files appear in My Computer & Address Bar
    ... > SERVICE JEFF-DZP8HX39G2 The machine-default permission settings do not ... > grant Local Activation permission for the COM Server application with ... > Ratcliff JEFF-DZP8HX39G2 The Adobe LM Service service was successfully ... > within the required timeout. ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Network shares cannot connect
    ... After a reboot, domain users cannot access any shares on the SBS server, ... Microsoft Online Newsgroup Support ... let's focus on the Users Shared Folder first. ... To check this permission, please click the Advanced button, ...
    (microsoft.public.windows.server.sbs)
  • Re: System.Security.SecurityException was unhandled
    ... Is it a must that I need to register the COM server to the machine using ... CAS permissions on the client machine, and the COM issue is a new problem. ... assembly actually has the permission in question. ... When I execute the application I received and error message. ...
    (microsoft.public.dotnet.security)