如何为一个引用c#asp.net中其他dll的类创建一个dll?

时间:2016-01-15 20:22:46

标签: c# c++ asp.net .net dll

我有以下课程,我试图从

创建一个dll
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NRules.Fluent.Dsl;
using NRule.site.Model;
using NRule.site.Utilities;

namespace NRule.site.Rules
{
    public class AllowAtleastOneCountryRule : Rule
    {
        public override void Define()
        {
            FundProfile productProfile = null;
            string str = RuleTexts.AllowAtleastOneCountryRule;
            bool enabled = AllRules.GetDict()[str];

            When()
                .Match<FundProfile>(() => productProfile)
                .Exists<FundProfile>( p => enabled, p => RuleViolation(p));

            Then()
                .Do(_ => productProfile.DisplayError(str));
        }

        bool RuleViolation(FundProfile pp)
        {
            if (pp.CountriesListP.Count==0)
                return true;
            if (pp.CountriesListP.Any(c => c.Allowed))
                return false;
            else
                return true;

        }
    }
}

如您所见,它有外部参考

using NRules.Fluent.Dsl;

以及层次结构中的其他一些类

using NRule.site.Model;
using NRule.site.Utilities;

当我尝试csc命令时,我得到了这个

csc /target:library /out:Mylib.dll AllowAtLeastOneCountryRule.cs
Microsoft (R) Visual C# Compiler version 4.0.30319.34209
for Microsoft (R) .NET Framework 4.5
Copyright (C) Microsoft Corporation. All rights reserved.

AllowAtleastOneCountryRule.cs(5,7): error CS0246: The type or namespace name
        'NRules' could not be found (are you missing a using directive or an
        assembly reference?)
AllowAtleastOneCountryRule.cs(6,18): error CS0234: The type or namespace name
        'Model' does not exist in the namespace 'NRule.site' (are you missing a
        assembly reference?)
AllowAtleastOneCountryRule.cs(7,18): error CS0234: The type or namespace name
        'Utilities' does not exist in the namespace 'NRule.site' (are you
        missing an assembly reference?)
AllowAtleastOneCountryRule.cs(11,47): error CS0246: The type or namespace name
        'Rule' could not be found (are you missing a using directive or an
        assembly reference?)
AllowAtleastOneCountryRule.cs(27,28): error CS0246: The type or namespace name
        'FundProfile' could not be found (are you missing a using directive or
        an assembly reference?)

如何引用所有程序集并将此类编译为DLL? 任何指导都会很棒。

1 个答案:

答案 0 :(得分:0)

您应该在代码中引用的命令中指定添加程序集。

csc /target:library reference:assembly_contained_your_types.dll /out:Mylib.dll AllowAtLeastOneCountryRule.cs
相关问题