zoukankan      html  css  js  c++  java
  • [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)]
  • 相关阅读:
    subprocess模块
    面向对象进阶
    python---面向对象学习
    vim命令---存阅
    python基础-软件目录开发规范
    装饰器、迭代器、生成器
    Python基础类型
    使用Git来撤销修改
    使用Git去管理修改
    了解Git的工作区和暂存区
  • 原文地址:https://www.cnblogs.com/kesalin/p/csharp_reference_path.html
Copyright © 2011-2022 走看看