亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

錯誤CS7068對類型“ConfigServices”的引用聲稱它在此程序集中定義

錯誤CS7068對類型“ConfigServices”的引用聲稱它在此程序集中定義

C#
莫回無 2023-08-13 15:48:06
我正在處理 .net core 2.2 中的一個項目,并且嘗試使用 .Net 4.6 中編碼的參考中的一個類。當我嘗試在我的 .net core 項目中使用它時,似乎 intelisense 識別了引用,我可以導航到它,但它也告訴我標題的錯誤。我不知道發生了什么,但我認為這可能是關于使用 .net core 和 .Net 4.6 的一些事情。這是類(.Net 4.6):    class ConfigServices : IEnumerable<ConfigService>, IEnumerable    {        public ConfigServices(IEnumerable<ConfigService> configServices, string activeService);        public ConfigService ActiveService { get; }        public bool IsEmpty { get; }        public bool Contains(ConfigService service);        public IEnumerator<ConfigService> GetEnumerator();    }這是我收到錯誤的地方(方法的第一行)(.Net core):            private async Task<string[]> configServicesToUse(string companyId, string serviceName)            {                var configServicesForCompany = (await UserInfo.ConfigServices(companyId)).Select(c => c.Name).ToArray();                if (string.IsNullOrWhiteSpace(serviceName) ||                    string.Equals(serviceName, "ALL", StringComparison.InvariantCultureIgnoreCase))                {                    return configServicesForCompany;                }                if (!configServicesForCompany.Contains(serviceName))                {                    throw new UnauthorizedAccessException("No access to requested service");                }                return new[] { serviceName };            }這是調用的方法(.Net core):        public static async  Task<ConfigServices> ConfigServices(string companyId)           {            var configurationService = new ConfigurationService();            var services =  await configurationService.ReadByCompanyId(int.Parse(companyId));            return new ConfigServices(services, ActiveConfigService);        }我得到的錯誤是“錯誤 CS7068 對類型“ConfigServices”的引用聲稱它在此程序集中定義,但未在源或任何添加的模塊中定義”。我尋找答案,但它們是針對框架和我沒有使用的東西。我希望你能幫助我,提前謝謝你:)
查看完整描述

1 回答

?
蕪湖不蕪

TA貢獻1796條經驗 獲得超7個贊

最后我遇到了問題。發生此錯誤是因為我的項目中具有與 nuget 包之一相同的命名空間引用。這使得 Visual Studio 對ConfigServices類的存在感到非常困惑。



查看完整回答
反對 回復 2023-08-13
  • 1 回答
  • 0 關注
  • 196 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號