错误CS0433类型"WebUtility"存在于两个地方

编程入门 行业动态 更新时间:2024-10-25 10:29:09
本文介绍了错误CS0433类型"WebUtility"存在于两个地方的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用Visual Studio 2017创建一个asp核心应用程序.我正在尝试使用Web实用工具对URL组件进行编码.

I'm creating an asp core app using Visual Studio 2017. I'm trying to encode a URL component using web utility.

var value = System.Net.WebUtility.UrlEncode("some text here");

当我将其包含在代码中时,我看到以下错误.我不知所措.我看不到project.json文件.我已经搜索了包含System.Runtime.Extensions的任何地方.

When I include that in my code, I see the below error. I'm at a loss as to finding the issue. I see no project.json file. I have searched for anyplace where System.Runtime.Extensions are being included.

我安装了以下软件包:AspNetCore,AspNetCore.Mvc,AspNetCore.StaticFiles,Core.App,PaulMiami.AspNetCore.Mvc.Recaptcha

I have the following packages installed: AspNetCore, AspNetCore.Mvc, AspNetCore.StaticFiles, Core.App, PaulMiami.AspNetCore.Mvc.Recaptcha

我试图在不解决问题的情况下删除验证码软件包.

I have tried to remove the captcha package without it fixing the issue.

错误CS0433类型'WebUtility'在'System.Runtime.Extensions,Version = 4.1.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'和'System,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'

Error CS0433 The type 'WebUtility' exists in both 'System.Runtime.Extensions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

有关此问题的其他帖子,我要求提供一个project.json文件,但我似乎没有.有什么想法吗?

Other posts I've seen about this issue ask for a project.json file, which I don't seem to have. Any thoughts?

更新1: 我尝试创建一个新的asp核心Web应用程序-开箱即用的所有默认值,然后我安装了PaulMiami.AspNetCore.Mvc.Recaptcha程序包,对WebUtility的调用在新创建的应用程序中可以正常工作.在导致此问题的现有应用程序中一定找不到某些东西.

Update 1: I tried to create a new asp core web app - all defaults out of the box, I then installed the PaulMiami.AspNetCore.Mvc.Recaptcha package, the call to WebUtility works fine in the newly created app. There must be something I'm not finding in the existing application that is causing this issue.

推荐答案

我发现了问题.

在从属关系"下,我注意到程序集"的一个条目,在其中是系统"的一个条目.我不确定它是如何到达的,但是删除它后,我的问题消失了,应用程序得以编译.

Under "Dependencies" I noticed an entry for Assemblies, and in that was an entry for "System". I’m not sure how it got there, but after removing it my issue went away and the app compiles.

以后,我将确保检查此位置.值得注意的是,我创建的新创建的开箱即用的asp核心Web应用程序在依赖项"列表中没有程序集"条目.我必须先添加一个程序包,然后再将其删除,这导致了此问题. (也许是asp pre-核心验证码框架是错误的?)

In the future, I’ll be sure to check this location. Of note, the newly created out of the box asp core web app I created had no entry for Assemblies in the Dependencies list. I must have added a package and then removed it, which caused this issue. (perhaps the asp pre- core captcha framework by mistake?)

更多推荐

错误CS0433类型"WebUtility"存在于两个地方

本文发布于:2023-11-09 10:27:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1572134.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   两个   类型   地方   quot

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!