[VS2010]在C#工程中设置Reference的相对路径

在C#工程中设置Reference的相对路径

罗朝辉 (http://kesalin.cnblogs.com/)

本文遵循“署名-非商业用途-保持一致”创作公用协议

要在C#工程中根据不同的项目配置使用不同的 reference,而该 reference 路径是相对路径,这时我们可以修改 csproj 项目文件,在其中添加 reference 路径,如下示例:
 
<ItemGroup>
<Reference Include="System" />
....
<Reference Include="log4net" Condition="'$(Configuration)'=='Debug'">
<HintPath>..\..\..\..\..\Output\bin_debug\log4net.dll</HintPath>
</Reference>
<Reference Include="log4net" Condition="'$(Configuration)'=='Release'">
<HintPath>..\..\..\..\..\Output\bin\log4net.dll</HintPath>
</Reference>
</ItemGroup>

Notes:
log4net 在.Net 4.0 中会报异常:
Inheritance security rules violated while overriding member: 'log4net.Util.ReadOnlyPropertiesDictionary.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)'. Security accessibility of the overriding method must match the security accessibility of the method being
可以在 log4net 工程中的 assembly(文件 AssemblyInfo.cs)里增加如下一句,重新编译即可:
[assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)]
posted @ 2012-03-21 10:35  飘飘白云  阅读(4891)  评论(0编辑  收藏  举报
本博客遵循 Creative Commons License “署名-非商业用途-保持一致”创作共用协议。 与我联系