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 8444287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:22:08+00:00 2026-06-10T09:22:08+00:00

I currently have an app.config with the following config value: <configuration> <runtime> <loadFromRemoteSources enabled=true

  • 0

I currently have an app.config with the following config value:

<configuration>
 <runtime>
  <loadFromRemoteSources enabled="true" />
 </runtime>
</configuration>

So far I have been able to remove everything else out of my app.config and configure things just using pure C# code except the loadFromRemoteSources.

Is there a way to enable loadFromRemoteSources through C# code?

I understand the pros and cons of having an app.config, but I would prefer not to have one.

Thanks!

  • 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-06-10T09:22:10+00:00Added an answer on June 10, 2026 at 9:22 am

    I can’t find any way to enable loadFromRemoteSources in code, and if there is, I doubt it would allow you to apply it to an application domain after it has been created. But I could be wrong!

    You could instead use the technique described in “More Implicit Uses of CAS Policy: loadFromRemoteSources“. They suggest creating a new application domain with PermissionState.Unrestricted, and loading remote assemblies into there. An application domain created this way does not throw NotSupportedException when you try to load a remote assembly.

    They describe this technique as a solution for when you want to load only some remote assemblies with full trust, and thus do not want to enable loadFromRemoteSources in your app.config. You could use the same technique, but load your entire program into the new app domain.

    Here is an example program which, when executed, immediately creates a new application domain with PermissionState.Unrestricted and runs itself in it:

    public class Program : MarshalByRefObject
    {
        public Program()
        {
            Console.WriteLine("Program is running.");
            Assembly remoteAssembly = Assembly.LoadFrom(
                @"\\server\MyRemoteAssembly.dll");
            IAddIn addIn = (IAddIn)remoteAssembly.CreateInstance("MyAddIn");
            addIn.Initialize();
        }
    
        static void Main()
        {
            // This program needs to run in an application domain with
            // PermissionState.Unrestricted, so that remote assemblies can be loaded
            // with full trust. Instantiate Program in a new application domain.
            PermissionSet permissionSet =
                new PermissionSet(PermissionState.Unrestricted);
            AppDomainSetup setup = new AppDomainSetup();
            setup.ApplicationBase =
                AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
            AppDomain appDomain = AppDomain.CreateDomain(
                "Trusted Domain", null, setup, permissionSet);
            appDomain.CreateInstance(
                Assembly.GetExecutingAssembly().FullName, "Program");
        }
    }
    
    public interface IAddIn
    {
        void Initialize();
    }
    

    And here is the source code for MyRemoteAssembly.dll, which you can put on your network share:

    public class MyAddIn : IAddIn
    {
        public void Initialize()
        {
            Console.WriteLine("Hello from a remote assembly!");
            Console.ReadLine();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have an app published on the App Store but I've just updated
I currently have a app on the market it saves some data with onRetainNonConfigurationInstance
I currently have an app that requires connection to a server in multiple activities.
I currently have an app deployed on Heroku which runs on two web dynos
I'm making a painting app, and I currently have the app at a point
Currently I have Windows App which is directly opening database connection (SQL Server is
currently I have an app that creates all sorts of different requests to Facebook
I currently have a deployed app (fortworth.herokuapp.com) that I am attempting to sort movies
I currently have one iPad app, but it now needs to become two. The
I currently have an iPhone app that lets the users take video, upload it

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.