Search code examples
c#asp.net.netexecutablerestrictions

C# .NET application fails to be started when user has restricted access to machine config


I am facing the following problem:

I have a C# .NET v4 application. It runs fine on most machines, but I am experiencing a weird behaviour:

On a machine with restricted access my .NET application won't run. I do not require admin permission to install the application, but it fails none the less. (Not on regular user accounts without admin permissions, but on really restricted machines, e.g. in companies)

The error I see in the logs is the following:

An error occurred loading a configuration file: Access to the path 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config' is denied.

I do not understand what I need to change in order to avoid this error. I use the Properties.Settings.Default.variable - mechanism to store some user-specific variables. I also use a custom Properties.MySettings.Default.variable - mechanism to store ephemeral settings. I removed those custom settings, but this did not solve the problem. I have no idea what is causing this problem. Is there even a way to solve it or will all .NET applications fail anyway when running on machines which offer only restricted access to machine.config?

I also noticed that other programs could not be installed on this machine, e.g. Chrome, throwing the same error.


Solution

  • Taken from: this post

    "From your description, I think that it's impossible to run a .NET application without assessing to machine.config file.

    In fact ,the machine configuration file, Machine.config, contains settings that apply to an entire computer. This file is located in the %runtime install path%\Config directory. Machine.config contains configuration settings for machine-wide assembly binding, built-in remoting channels, and ASP.NET.

    The configuration system first looks in the machine configuration file for the appSettings Element (General Settings Schema) and other configuration sections that a developer might define.

    For more information, please see Machine Configuration Files."

    Taken from here...

    "The runtime uses the following steps to resolve an assembly reference:

    Determines the correct assembly version by examining applicable configuration files, including the application configuration file, publisher policy file, and machine configuration file. If the configuration file is located on a remote machine, the runtime must locate and download the application configuration file first."