如何在 c# asp.net 中为引用其他 dll 的一个类创建 dll
本文关键字:dll 创建 一个 其他 asp net 引用 | 更新日期: 2023-09-27 18:30:32
我有以下类,我正在尝试从中制作一个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?任何指导都会很棒。
应在代码中引用的命令中指定附加程序集。
csc /target:library reference:assembly_contained_your_types.dll /out:Mylib.dll AllowAtLeastOneCountryRule.cs