code-access-security

How can I run an exe or windows service in medium trust?

寵の児 提交于 2019-12-02 14:26:13
问题 I would like to run exes and Windows Services in Medium Trust, but all the literature I can find suggests using <system.web> <trust level="Medium"/> </system.web> for ASP.NET, so I have tried that but using code from How do you check if you are running in Medium Trust environment in .NET? it still appears to have full trust. What is the correct way to do this? 回答1: The available approaches depend on the .NET version. Prior to .NET 4.0, the CLR enforced CAS policy, which made it possible to

System.Type.GetCustomAttributes on an assembly loaded from a network share is not showing all attributes

半世苍凉 提交于 2019-12-02 13:03:25
问题 I have a managed dll – repro.dll, which contains class TestModuleCommand decorated with 2 attributes: System.ObsoleteAttribute and System.Management.Automation.CmdletAttribute (comes from System.Management.Automation.dll which is in the GAC in Windows 7) namespace Test { [System.Obsolete] [System.Management.Automation.Cmdlet("Test", "Module")] public class TestModuleCommand : System.Management.Automation.PSCmdlet { protected override void ProcessRecord() { this.WriteObject("In test-module");

How can I run an exe or windows service in medium trust?

笑着哭i 提交于 2019-12-02 04:45:45
I would like to run exes and Windows Services in Medium Trust, but all the literature I can find suggests using <system.web> <trust level="Medium"/> </system.web> for ASP.NET, so I have tried that but using code from How do you check if you are running in Medium Trust environment in .NET? it still appears to have full trust. What is the correct way to do this? The available approaches depend on the .NET version. Prior to .NET 4.0, the CLR enforced CAS policy, which made it possible to restrict permissions for any assembly. However, as of .NET 4.0, the CLR no longer applied CAS policy unless

How does one fix the “'System.Security.Permissions.SecurityAction.RequestMinimum' is obsolete” compilation error?

一笑奈何 提交于 2019-12-01 15:07:25
I received the following compilation warning as a error while upgrading some ASP.NET code from .NET 3.5: 'System.Security.Permissions.SecurityAction.RequestMinimum' is obsolete. The attribute has bee applied on the assebly level: [assembly: System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.RequestMinimum, Execution=true)] Also the code makes use of the P&P Web Client Software Factory, specificly the ObjectBuilder.WCSFExtensions library. Also it the code is providing some role provider implementations. Keep in mind this code is used as Framework code in

How does one fix the “'System.Security.Permissions.SecurityAction.RequestMinimum' is obsolete” compilation error?

雨燕双飞 提交于 2019-12-01 14:02:02
问题 I received the following compilation warning as a error while upgrading some ASP.NET code from .NET 3.5: 'System.Security.Permissions.SecurityAction.RequestMinimum' is obsolete. The attribute has bee applied on the assebly level: [assembly: System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.RequestMinimum, Execution=true)] Also the code makes use of the P&P Web Client Software Factory, specificly the ObjectBuilder.WCSFExtensions library. Also it the code

How can I use CAS in .NET 4 to lock down my MEF extensions?

依然范特西╮ 提交于 2019-12-01 09:11:19
I have an application in .NET 4 that uses MEF for extensibility. My main application has three assemblies: Host , Application and Contracts . Host is the "boot-strapping" executable that creates the container and does the composition. Application contains the logic of my application, and more extension points for 3rd parties. Contracts contains the interfaces (and some helper classes) that are used in the extension points. Therefore, someone developing a 3rd party application has to include a reference to Contracts , but not to Application . I'm thinking that my security model should look like

How can I use CAS in .NET 4 to lock down my MEF extensions?

家住魔仙堡 提交于 2019-12-01 06:25:30
问题 I have an application in .NET 4 that uses MEF for extensibility. My main application has three assemblies: Host , Application and Contracts . Host is the "boot-strapping" executable that creates the container and does the composition. Application contains the logic of my application, and more extension points for 3rd parties. Contracts contains the interfaces (and some helper classes) that are used in the extension points. Therefore, someone developing a 3rd party application has to include a

SecurityAttribute.Unrestricted issue

拥有回忆 提交于 2019-11-30 19:04:30
问题 I am confused about this property, as mentioned here, http://msdn.microsoft.com/en-us/library/system.security.permissions.securityattribute.unrestricted.aspx we could give it full or non-full. My confusion is for permission in a straightforward understanding, there should be only two status -- granted and not-granted, what does th full and non-full mean? 回答1: I have previously used the Unrestricted attribute in the classic way: The following code is a request stating that an assembly must

.NET Code Access Security: Useful or just overcomplicated?

扶醉桌前 提交于 2019-11-30 17:42:52
see also Is “Code Access Security” of any real world use? I want to get some other opinions on this... I like the idea of Code Access Security for desktop applications. But in the lifetime of .NET I have to admit I've never actually had a situation where CAS has actually blocked something to my benefit. I have, however, had many times where something as simple as sharing a quick .NET application across a mapped drive becomes an enterprise code access nightmare. Having to break out caspol.exe to create trusted path rules and having no clear way of knowing why something failed makes it seem like

“dynamic operations can only be performed in homogenous appdomain” error while launching PowerShell

早过忘川 提交于 2019-11-30 17:38:41
I have a powershell script that I am trying to execute from WCF REST service.I am using the System.Management.Automation and System.Management.Automation.Runspaces assemblies. The C# code looks like this: Command command = new Command(path); command.Parameters.Add(param); RunspaceConfiguration runspaceConfiguration = RunspaceConfiguration.Create(); using (Runspace runspace = RunspaceFactory.CreateRunspace(runspaceConfiguration)) { runspace.Open(); ... other code } This error happens here once I try to execute the open statement: Dynamic operations can only be performed in homogenous AppDomain.