Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET - Can App.Config Be Embedded?

Tags:

c#

.net

vb.net

According to this: https://msdn.microsoft.com/en-us/library/jj152935%28v=vs.110%29.aspx

In order for .NET Framework 4/4.5 to work with .NET 2.0 apps, an app.config must be provided.

I want to maximize the compatibility of my .NET 2.0 apps.

I need it to work with PCs that only have .NET 2.0 installed or .NET 4 installed.

The problem is that, having an app.config always present with the executable is not as professional as I want it to look like.

My App is a standalone app, so having an app.config to make it work does not really make it a standalone app.

This is the settings inside the app.config, you see it's not really my settings its a runtime version settings.

<configuration>
  <startup>
    <supportedRuntime version="<version>"/>
  </startup>
</configuration>

The app will run without the app.config in .NET 2.0 framework, but if within .NET 4.0 framework the app.config is required.

Is there any fix for this?

Edit:

My question is different from: How do I compile my App.config into my exe in a VS2010 C# console app?

As this tackles .NET runtime-version settings, not the app's settings itself.

like image 453
Malcolm Who Avatar asked Aug 01 '15 12:08

Malcolm Who


People also ask

Where should app config be located?

A typical location would be: C:\Windows\System32\inetsrv\ApplicationHost. config.

Does app config get compiled?

Now you might be wondering what happens behind the scenes. Well, when you compile your application, the compiler actually copies the app. config file to the output folder, but gives it another name: When you start your application (ConsoleApp1.exe in our example), the matching config file will be loaded too.

Can I use app config in .NET Core?

ASP.NET Core builds a single, key-value-based configuration object using settings from one or more configuration providers. App Configuration offers a . NET configuration provider library. Therefore, you can use App Configuration as an extra configuration source for your app.

Where are .NET application settings stored?

Settings. settings is located in the My Project folder for Visual Basic projects and in the Properties folder for Visual C# projects. The Project Designer then searches for other settings files in the project's root folder. Therefore, you should put your custom settings file there.


1 Answers

A single .exe will not be very professional, you can take a look at some alternatives like ClickOnce

Some of the key features are it make the update process much more simple, and efficient, for example the GitHub windows client is delivered using ClickOnce.

There plenty of other alternatives to deliver your application like Wix

However it also possible to embed resources in the dlls like take a look here. But as marc_s said embedding the app.config does not make much sense.

Hope this helps.

like image 89
dnlgmzddr Avatar answered Oct 31 '22 20:10

dnlgmzddr