7

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.

riQQ
  • 9,878
  • 7
  • 49
  • 66
Malcolm Who
  • 433
  • 5
  • 13
  • 5
    What on earth makes you think it's not professional?? – DavidG Aug 01 '15 at 12:31
  • 1
    It is a standalone app, having an app.config with it in order for it to work does conflict with the meaning of being a standalone app. – Malcolm Who Aug 01 '15 at 12:34
  • 8
    Having an `app.config` makes it possible to *change* certain settings, like database connections. This is **very professional** to have! Embedding this into the EXE would **defeat** the whole purpose of having a config file in the first place! You could just as easily **hard-code** all your settings directly in code.... but that would be **very UNprofessional!** – marc_s Aug 01 '15 at 12:34
  • 3
    I think you misunderstand what a standalone app is. It doesn't mean you don't need other components to go with it. At the very last you also need the .Net Framework installed on that machine. – DavidG Aug 01 '15 at 12:36
  • I edited the question, the settings inside the app.config isn't really necessary for the app to run, it is for the system for it to know what version of .NET is the app using. – Malcolm Who Aug 01 '15 at 12:38
  • 1
    I see, thank you for your responses, tho I want it to be a single file that can do a task which has a greater compatibility across .NET frameworks. – Malcolm Who Aug 01 '15 at 12:39
  • 1
    possible duplicate of [How do I compile my App.config into my exe in a VS2010 C# console app?](http://stackoverflow.com/questions/4586210/how-do-i-compile-my-app-config-into-my-exe-in-a-vs2010-c-sharp-console-app) – GSerg Aug 01 '15 at 12:41
  • It's not a duplicate, as I've said the app will run without the app.config in .NET 2.0 framework, but if with in .NET 4.0 framework the app.config is required. – Malcolm Who Aug 01 '15 at 12:42
  • 1
    @MalcolmWho Does it really matter *why* you want to embed the config? You want the config to be embedded. This matter is discussed in that question (and the questions linked to from there). – GSerg Aug 01 '15 at 13:07
  • @GSerg No not really, you see the app.config is enforced by Microsoft just recently with the release of newer version of windows. https://msdn.microsoft.com/en-us/library/windows/desktop/hh848079(v=vs.85).aspx I really don't understand what's in that you said "the same or duplicate". – Malcolm Who Aug 02 '15 at 01:48

1 Answers1

2

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.

Community
  • 1
  • 1
dnlgmzddr
  • 628
  • 1
  • 7
  • 25
  • 8
    I'm having the exact same issue. This doesn't answer the question. Sorry. It's not a matter of professionalism. It's a matter of the thing doesn't work when you run on a .NET 4 system. These aren't settings that need to change. Distributing a .config and Wixing/ClickOncing it up just for the sake of a config is overkill for this – Craig Brett Feb 21 '17 at 15:41