简体   繁体   English

为什么 Visual-Studio 为一个应用程序自动生成 app.config 而不是另一个应用程序?

[英]Why has Visual-Studio auto-generated app.config for one application but not for another?

I have a solution with 3 projects.我有一个包含 3 个项目的解决方案。 One is a library, the other two are console apps which both use this library.一个是库,另外两个是控制台应用程序,它们都使用这个库。

I was having problems running one of the applications - a call into my lib that calls System.Buffers.Binary.BinaryPrimitives was generating an assembly exception.我在运行其中一个应用程序时遇到问题 - 对调用System.Buffers.Binary.BinaryPrimitives库的调用生成了程序集异常。

I noticed their app.config files are different:我注意到他们的 app.config 文件是不同的:

App A应用程序A

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
    </startup>

App B应用程序B

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
    </startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>
</configuration>

All those additional assemblies are dependencies of my library project, so should presumably be in both.所有这些额外的程序集都是我的库项目的依赖项,所以大概应该在两者中。 Why the library project itself isn't referenced I don't know.我不知道为什么没有引用图书馆项目本身。

I have never touched the config files so they are autogenerated but not equivalently.我从未接触过配置文件,因此它们是自动生成的,但不是等效的。 Why?为什么? And how can I get VS to regenerate?我怎样才能让 VS 重新生成?

The only difference in approach I can think of is that when I started using my library in App A, VS suggested adding a reference which I accepted.我能想到的方法的唯一区别是,当我开始在 App A 中使用我的库时,VS 建议添加一个我接受的参考。 In App B, I believe I added the dependency manually.在 App B 中,我相信我手动添加了依赖项。

References are mentioned in csproj file, you can access it by right clicking your project, unload, edit. csproj 文件中提到了引用,您可以通过右键单击您的项目、卸载、编辑来访问它。 there it will look something like this.在那里它看起来像这样。 also you can manage your project references under Reference 'folder'您也可以在参考“文件夹”下管理您的项目参考

<ProjectReference Include="..\YourProject.csproj">
  <Project>{68836A56-12B9-4740-A78D-78F027336CBF}</Project>
  <Name>YourProject</Name>
</ProjectReference>

Mostly you do not edit app.config for reference purposes.大多数情况下,您不会出于参考目的编辑 app.config。 Shortly, app.config is used for runtime settings.很快,app.config 用于运行时设置。

暂无
暂无

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

相关问题 在 Visual Studio for mac 中为控制台应用程序添加 app.config 文件 - Add app.config file for console application in Visual studio for mac 在使用 visual studio 2019 运行应用程序时,如何防止在 Asp.Net Core API 3.1 中自动生成 web.config? - How to prevent auto-generated web.config in Asp.Net Core API 3.1 while running the application using visual studio 2019? Visual Studio服务参考和自动生成的代理类-为什么不应该在您的类/项目中传递它们? - Visual Studio Service Reference, and Auto-Generated Proxy Classes - Why should they not be passed around your classes/projects? 在 Visual Studio 中重建 app.config? - Rebuilding app.config in visual studio? 自动生成的代码在Visual Studio 2015中引发很多警告 - auto-generated code throw lots of warning in visual studio 2015 如何模拟Visual Studio自动生成的SOAP客户端? - How to mock SOAP client that was auto-generated by Visual Studio? Visual Studio自动生成文件开头的那些字符是什么? - What are those characters at the beginning of Visual Studio auto-generated files? 在 Visual Studio 中包含自动生成的静态内容 - Including auto-generated static content in Visual Studio 从另一个应用程序更改app.config - Changing app.config from another application 在Visual Studio Professional 2017中添加app.config(应用程序配置文件) - Adding app.config (Application Configuration File) in Visual Studio Professional 2017
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM