Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3942650
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:41:19+00:00 2026-05-20T00:41:19+00:00

I am working through the Microsoft .Net Framework–Application Development Foundation Training Kit book Chapter

  • 0

I am working through the Microsoft .Net Framework–Application Development Foundation Training Kit book Chapter 8 Lesson 2: Configuring Application Domains

ShowWinIni being the assembly name for the program I want to execute

object[] hostEvidence = { new Zone(SecurityZone.MyComputer) };
Evidence e = new Evidence(hostEvidence, null);

// Create an AppDomain.
AppDomain d = AppDomain.CreateDomain("New Domain", e);

// Run the assembly
d.ExecuteAssemblyByName("ShowWinIni");

When I execute:

AppDomain d = AppDomain.CreateDomain("New Domain", e);

I get the following message:
“This method implicitly uses CAS policy, which has been obsoleted by the .NET Framework. In order to enable CAS policy for compatibility reasons, please use the NetFx40_LegacySecurityPolicy configuration switch. Please see http://go.microsoft.com/fwlink/?LinkID=155570 for more information.”

I can execute the assembly fine when I create an AppDomain without an Evidence object.

Of course, I visited http://go.microsoft.com/fwlink/?LinkID=155570 but I am still confused as to how to create an application domain with specified privileges.

The next most helpful site I found was http://msdn.microsoft.com/en-us/library/bb763046.aspx but my StrongName object computes to NULL.

StrongName fullTrustAssembly =
     typeof(Program).Assembly.Evidence.GetHostEvidence<StrongName>();

Program being the name of the class implementing all this code.

Thanks in advance for your advice and tips!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T00:41:19+00:00Added an answer on May 20, 2026 at 12:41 am

    I found a way to make the original code example work without having to enable NetFX40_LegacySecurityPolicy.

    EvidenceBase[] hostEvidence = { new Zone(SecurityZone.MyComputer) };
    Evidence e = new Evidence(hostEvidence, null);
    
    AppDomain d = AppDomain.CreateDomain("New Domain", e);
    
    d.ExecuteAssemblyByName("ShowWinIni");
    

    This will not work if you change the SecurityZone to Internet, it will try to use the obsoleted CAS security policy resulting in a NotSupportedException. What I want is a SecurityException… meaning that the assembly I want to execute does not have the permissions it needs.

    To execute an assembly in an AppDomain with restricted permissions, you need to use sandboxing. The best example of sandboxing I found is here:
    http://www.simple-talk.com/dotnet/.net-framework/whats-new-in-code-access-security-in-.net-framework-4.0—part-i/

    I think that page also explains the changes made to CAS in 4.0 very well!

    Many sources, including MSDN, had me convinced I needed to provide a StrongName array when calling:

    AppDomain.CreateDomain( string friendlyName,
                            Evidence securityInfo,
                            AppDomainSetup info,
                            PermissionSet grantSet,
                            params StrongName[] fullTrustAssemblies);
    

    As stated in my original post, I was (and still am) having trouble getting a StrongName object instead of null. Turns out I didn’t even need it!

    This is my completed example for sandboxing:

    Evidence ev = new Evidence();
    ev.AddHostEvidence(new Zone(SecurityZone.Internet));
    PermissionSet internetPS = SecurityManager.GetStandardSandbox(ev);
    
    AppDomainSetup adSetup = new AppDomainSetup();
    adSetup.ApplicationBase = Path.GetFullPath(pathToUntrusted);
    
    AppDomain newDomain = AppDomain.CreateDomain("Sandbox Domain", null, adSetup, internetPS);
    
    newDomain.ExecuteAssemblyByName(untrustedAssembly);
    

    pathToUntrusted = a string representation of the file path to my assembly

    untrustedAssembly = a string representation of the assembly name

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently working my way through the Microsoft SQL Server 2008 - Database Development
I'm working through Cocoa Programming for Mac OS X (3rd ed) and in chapter
I'm working through the Data Binding chapter in Pro WPF in C# 2008. They
Microsoft provides a number of command line tools for working with asp.net applications. I
I've been working on an ASP.NET MVC 2 (.NET 4.0, Visual Studio 2010) application
I am currently working on a c# .NET desktop application that will be communicating
Now that Microsoft has revamped their workflow framework in Windows Workflow Foundation 4, what
I've been working through Practical Common Lisp and as an exercise decided to write
I'm working through previous years ACM Programming Competition problems trying to get better at
I'm currently working through an assignment that deals with Big-O and running times. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.