命名空间错误中不存在类型资源 [英] type resources does not exist in namespace error

查看:45
本文介绍了命名空间错误中不存在类型资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

还有一个问题.我几乎完成了我的项目,但觉得我必须更改项目的命名空间.但是我没有使用 refactor --> rename ,而是选择了我的命名空间,编辑 --> 查找和替换并将我的整个解决方案替换为不同的命名空间(因此在解决方案中的任何地方,例如命名空间或文本name1"存在的地方,都是现在变成了name2").

Got another problem. I had almost finished my project but felt like I had to change the namespace of the project. But instead of using refactor --> rename , I selected my namespace, edit --> find and replace and replaced my whole solution with a different namespace (so everywhere in the solution where for example the namespace or text "name1" exists, is now changed into "name2").

但是现在我遇到了大约 16 个错误,所有错误都说同样的话:命名空间 name1 中不存在类型或命名空间资源".

But now I get around 16 errors all saying the same thing: "The type or namespace "resources" does not exist in namespace name1".

     this.centerPanel.BackgroundImage = global::login_DragDrop.Properties.Resources.oeftest;

那么例如在这行代码中(主要是在designer.cs中)资源是红色的?

So for example in this line of code (mainly in the designer.cs) resources is colored red?

有关如何解决此问题的任何提示?

Any hints on how to fix this?

推荐答案

您需要在资源文件上运行代码生成以获取正确的命名空间.

You need to run the code generation on the resource file to get the correct namespace there as well.

请按照以下步骤操作:

  • 打开项目属性(右击>属性)
    • 点击应用部分
    • 输入您喜欢的默认命名空间
    • 关闭并保存您的属性
    • 右键单击 Resources.resx 文件
    • 选择运行自定义工具"(或 alt+L)

    这将再次运行资源文件的代码生成.生成的代码使您可以对资源字符串中的值进行强类型访问.

    This runs the code generation for the resource files again. The generated code makes that you have strongly typed access to the values in your resource strings.

    这篇关于命名空间错误中不存在类型资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆