简体   繁体   English

.NET - 可以嵌入App.Config吗?

[英].NET - Can App.Config Be Embedded?

According to this : https://msdn.microsoft.com/en-us/library/jj152935%28v=vs.110%29.aspx 根据这个: 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. 为了使.NET Framework 4 / 4.5能够与.NET 2.0应用程序一起使用,必须提供app.config。

I want to maximize the compatibility of my .NET 2.0 apps. 我想最大化我的.NET 2.0应用程序的兼容性。

I need it to work with PCs that only have .NET 2.0 installed or .NET 4 installed. 我需要它与只安装了.NET 2.0或安装了.NET 4的PC一起使用。

The problem is that, having an app.config always present with the executable is not as professional as I want it to look like. 问题是,让app.config始终与可执行文件一起出现并不像我希望的那样专业。

My App is a standalone app, so having an app.config to make it work does not really make it a standalone app. 我的应用程序是一个独立的应用程序,所以有一个app.config使其工作并不真正使它成为一个独立的应用程序。

This is the settings inside the app.config, you see it's not really my settings its a runtime version settings. 这是app.config中的设置,你看它不是我的设置它的运行时版本设置。

<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. 该应用程序将在.NET 2.0框架中运行时没有app.config,但如果在.NET 4.0框架内,则需要app.config。

Is there any fix for this? 有没有解决这个问题?

Thank you for reading. 谢谢你的阅读。

Edit: 编辑:

My question is different from: How do I compile my App.config into my exe in a VS2010 C# console app? 我的问题不同于: 如何在VS2010 C#控制台应用程序中将我的App.config编译到我的exe中?

As this tackles .NET runtime-version settings, not the app's settings itself. 因为这解决了.NET运行时版本设置,而不是应用程序的设置本身。

A single .exe will not be very professional, you can take a look at some alternatives like ClickOnce 单个.exe不是很专业,你可以看看像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. 一些关键功能是使更新过程更简单,更高效,例如使用ClickOnce提供GitHub Windows客户端。

There plenty of other alternatives to deliver your application like Wix 还有许多其他替代方案可以像Wix一样提供您的应用程序

However it also possible to embed resources in the dlls like take a look here . 但是也可以在dll中嵌入资源,比如看看这里 But as marc_s said embedding the app.config does not make much sense. 但正如marc_s所说嵌入app.config没有多大意义。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM