Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I specify supportedRuntime (or any other config parameter) without a .config file in .net?

I have a WinForms app that should be really easy to deploy with just and .exe file. It uses framework 2.0, and so it does not work on Windows 8 by default. If I include a .config file with the following parameters, it works fine on W8:

<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
    <supportedRuntime version="v2.0.50727"/>
  </startup>
</configuration>

However, now I have to deploy two files and this is not acceptable. Is there some thing I can do to "embed" those parameters into the exe itself?

I have tried using WinZip self extractor, but it's not an option either, because I cannot customize its interface.

like image 948
rgargente Avatar asked Sep 07 '12 09:09

rgargente


People also ask

Which file is the place where we can change the configuration of the app?

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.

What is SKU in app config?

A string value that specifies the stock-keeping unit (SKU), which in turn specifies which . NET Framework release this application supports. Starting with . NET Framework 4.0, the use of the sku attribute is recommended.


1 Answers

.NET executable contains small piece of native code, which is intended to load appropriate CLR version into a process.

Loader calls shim (MSCOREE.DLL, .NET executable has native dependency from this DLL) to load CLR (CLRCreateInstance in v4).
Content of <startup> configuration element is processed by the shim.

This means, you can't process <startup> element in managed code, because there's no CLR (and any managed code) at this moment. The only way is to write your own CLR host. I think, it is much easier to ship your application with config file, or build a version for .NET 4/4.5.

like image 156
Dennis Avatar answered Oct 15 '22 15:10

Dennis