[英]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 文件是不同的:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<?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.