我正在尝试从带有 net 2.0 的 Visual Studio 2008 迁移旧项目(游戏编辑器),似乎与带有 net 4.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
System.Windows.Forms.MenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
之类的值,或者只是在 resx 中创建 MenuStrip 字符串并向其中添加相同的内容..虽然没有帮助,但如何解决这个问题?抱歉,我想这可能是个愚蠢的问题。
弄清楚了这一点,您需要检查 .resx 的“资源逻辑名称”并手动设置它,或者更好地在宏中为每个项目创建根命名空间,并将其添加到 .resx“逻辑名称”,例如: $(RootNamespace) .%(文件名).资源.