为什么 Visual-Studio 为一个应用程序自动生成了 app.config,而没有为另一个应用程序自动生成 ap



我有一个包含 3 个项目的解决方案。一个是库,另外两个是控制台应用程序,它们都使用此库。

我在运行其中一个应用程序时遇到问题 - 调用我的库调用System.Buffers.Binary.BinaryPrimitives生成程序集异常。

我注意到他们的 app.config 文件不同:

应用 A

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

应用 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>

所有这些附加程序集都是我的库项目的依赖项,因此可能应该同时存在于两者中。我不知道为什么没有引用库项目本身。

我从未接触过配置文件,因此它们是自动生成的,但不是等效的。为什么?我怎样才能让VS再生?

我能想到的唯一方法区别是,当我开始在应用程序 A 中使用我的库时,VS 建议添加一个我接受的引用。在应用程序 B 中,我相信我手动添加了依赖项。

csproj文件中提到了引用,您可以通过右键单击项目,卸载,编辑来访问它。 那里看起来像这样。 您也可以在引用"文件夹"下管理您的项目引用

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

大多数情况下,您不会出于参考目的编辑 app.config。很快,app.config 将用于运行时设置。

最新更新