提问人:taburetka 提问时间:9/29/2023 最后编辑:taburetka 更新时间:10/1/2023 访问量:89
MenuStrip 的 MissingManifestResourceException 错误以及如何修复它
MissingManifestResourceException error with MenuStrip and how to fix it
问:
我正在尝试将旧项目(游戏编辑器)从带有 net 2.0 的 Visual Studio 2008 迁移到带有 net 2.8 的 2022 年,可悲的是我对 dotnet 非常熟悉,并且在编辑器启动过程中遇到了错误。
System.Resources.MissingManifestResourceException:“找不到适合指定区域性或非特定区域性的任何资源。确保“editor.window_ide.resources”在编译时正确嵌入或链接到程序集“编辑器”中,或者所需的所有附属程序集都是可加载的并已完全签名。
最后一行的问题:
resources->ApplyResources(this->menuStrip, L"menuStrip"); this->menuStrip->Name = L"menuStrip";
基本上,似乎一切都是使用默认编辑器命名空间创建的标准方式。据此申报的资源:
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
namespace editor {
public ref class window_ide : public System::Windows::Forms::Form
{
typedef Form super;
public:
window_ide( editor_world& world ) :
m_editor_world ( world )
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
in_constructor ( );
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~window_ide()
{
if (components)
{
delete components;
}
custom_finalize ( );
}
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container^ components;
private: System::Windows::Forms::MenuStrip^ menuStrip;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(window_ide::typeid));
// other declared components
this->menuStrip = (gcnew System::Windows::Forms::MenuStrip());
this->menuStrip->SuspendLayout();
this->SuspendLayout();
// menuStrip
this->menuStrip->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(5) {this->FileMenuItem, this->EditMenuItem, this->ViewMenuItem, this->ToolsMenuItem, this->HelpMenuItem});
this->menuStrip->SuspendLayout();
resources->ApplyResources(this->menuStrip, L"menuStrip");
this->menuStrip->Name = L"menuStrip";
}
#pragma endregion
};
} // namespace editor
我试图编辑resx文件并将 menuStrip.Name 值更改为类似的东西,或者只是在resx中创建MenuStrip字符串并向其添加相同的东西。虽然它没有帮助,但如何解决这个问题?对不起,我想这可能是一个愚蠢的问题。System.Windows.Forms.MenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
答:
弄清楚这一点后,您需要检查 .resx 的“资源逻辑名称”并手动设置它,或者最好在宏中为每个项目创建根命名空间,并将其添加到 .resx “逻辑名称”中,例如:$(RootNamespace).%(Filename).resources。
评论