使用 HttpUtility.UrlEncode() 会使程序集的命名空间“消失”?

发布于 2024-10-23 22:21:07 字数 528 浏览 5 评论 0原文

我有 2 个 C# 项目(我们称它们为 A 和 B)。项目A被编译为类库,项目B被编译为Windows应用程序。项目B添加了对项目A的引用。正常情况下,它们运行良好,没有任何问题。

我添加了一行使用 HttpUtility.UrlEncode() 来项目 A:

字符串编码 = HttpUtility.UrlEncode(queryString);

我还添加了“使用 System.Web”和对 System.Web.dll 的引用。虽然项目 A 仍然可以成功构建,但是当我构建项目 B 时,它给出了错误,说项目 A 的命名空间不存在。删除使用 HttpUtility.UrlEncode() 的行可以解决问题,但我确实需要该方法。

请帮我!提前致谢。

编辑:我发现问题:我将项目B的“目标框架”属性设置为“.net Framework 4 client profile”,这似乎不支持System.Web。只需将其更改为“.net Framework 4”即可正常工作。

I have 2 C# projects (let's call them A and B). Project A is compiled to Class library and project B is compiled to Windows Application. Project B is added a reference to project A. Normally, they run well, without any problem.

I added a line that use HttpUtility.UrlEncode() to project A:

string encoded = HttpUtility.UrlEncode(queryString);

and I also added 'using System.Web' and a reference to System.Web.dll. While project A still be built successfully, when I build project B, it gave me errors said that the namespace of project A does not exist. Removing the line that use HttpUtility.UrlEncode() solve the problem, but I really need that method.

Please help me! Thanks in advance.

Edit: I've found the problem: I set the "target framework" property of project B as ".net framework 4 client profile", which seems not support System.Web. Just change it to ".net framework 4" and it works fine.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蓝天 2024-10-30 22:21:07

发布收到的实际错误消息及其所有怪癖可能会更有帮助,以获得更多帮助。

It may be more helpful to post the actual error message received with all its quirks for more assistance to be given.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文