Programing

MissingManifestResourceException은 무슨 뜻이고 어떻게 해결 하죠?

crosscheck 2020. 6. 18. 21:18
반응형

MissingManifestResourceException은 무슨 뜻이고 어떻게 해결 하죠?


그 상황:

  • 라는 클래스 라이브러리가 RT.Servers있습니다 (유형의 리소스가 포함되어 byte[]있지만 중요하지 않다고 생각합니다).
  • 동일한 클래스 라이브러리에는 해당 자원 중 하나를 리턴하는 메소드가 포함되어 있습니다.
  • 해당 단일 메소드 만 호출하는 간단한 프로그램 (해당 라이브러리 참조)이 있습니다.

내가 얻을 MissingManifestResourceException다음과 같은 메시지가 :

지정된 문화 또는 중립 문화에 적합한 자원을 찾을 수 없습니다. 컴파일시 "Servers.Resources.resources"가 어셈블리 "RT.Servers"에 올바르게 포함되거나 링크되었는지 또는 필요한 모든 위성 어셈블리가로드 가능하고 완전히 서명되었는지 확인하십시오.

나는 문화 나 어셈블리 서명을 가지고 놀지 않았으므로 여기서 무슨 일이 일어나고 있는지 모르겠습니다. 또한 이것은 동일한 라이브러리를 사용하는 다른 프로젝트에서 작동합니다. 어떤 아이디어?


이 문제를 해결하기 위해 Resources.resx솔루션 탐색기에서 파일 을 마우스 오른쪽 단추로 클릭하고 사용자 지정 도구 실행을 클릭하기 만하면 됩니다. 자동 생성 된 Resources.Designer.cs파일 이 다시 생성 됩니다.

.resx 파일을 프로젝트에 수동으로 추가 한 경우 파일의 사용자 정의 도구 특성을 "ResXFileCodeGenerator"로 설정해야합니다.

프로젝트 설정에서 어셈블리의 "기본 네임 스페이스"를 변경하면 네임 스페이스가 일치하지 않기 때문에 문제가 발생합니다. (나는 (이전) "Servers"에서 (현재)로 변경했습니다 "RT.Servers".)

의 자동 생성 코드 Resources.Designer.cs에는 다음 코드가 있습니다.

internal static global::System.Resources.ResourceManager ResourceManager {
    get {
        if (object.ReferenceEquals(resourceMan, null)) {
            global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Servers.Resources", typeof(Resources).Assembly);
            resourceMan = temp;
        }
        return resourceMan;
    }
}

리터럴 문자열 "Servers.Resources"을로 변경해야했습니다 "RT.Servers.Resources". 이 작업을 수동으로 수행했지만 사용자 지정 도구를 실행하면 동일하게 수행됩니다.


방금 오늘이 문제가 발생 했으며 실제로이 문제를 해결하는 이 Microsoft 도움말 및 지원 페이지찾았습니다 .

내 파일 맨 위에 전역 네임 스페이스에 몇 명의 대의원이 있었으며 MissingManifestResourceException프로그램을 실행할 때 갑자기이 줄에 도착했습니다 .

this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));

그런 다음 대리자를 네임 스페이스로 옮겼는데 같은 오류가 발생했습니다. 마지막으로 델리게이트를 해당 파일의 유일한 클래스에 넣었고 오류가 사라졌지 만 해당 클래스 또는 네임 스페이스의 델리게이트를 원하지 않았습니다.

그런 다음 위의 링크를 보았습니다.

이 문제를 해결하려면 다른 모든 클래스 정의를 폼의 클래스 정의 뒤에 나타나도록 이동하십시오.

로컬 네임 스페이스 외부에서 해당 파일의 맨 아래에 "클래스 정의"를 고려하지 않는 델리게이트를 추가했는데 프로그램이 MissingManifestResourceException더 이상 얻지 못했습니다 . 짜증나는 오류입니다. 그러나 자동 생성 코드를 수정하는 것보다 더 강력한 솔루션처럼 보입니다. :)


비슷한 문제가 발생했지만 OP가 원인이 아니라는 것을 알고 있지만 나중에 다른 사람 이이 문제를 겪을 경우 답변을 얻을 수 있도록 여기에 게시합니다.

디자이너 클래스 앞에 클래스를 추가하면 MissingManifestResourceException런타임에 예외 발생합니다 (컴파일 시간 오류 또는 경고 없음).

Visual Studio에서는 디자이너가 파일의 첫 번째 클래스를 사용해야합니다.

자세한 내용은 이 게시물을 참조하십시오 .


나는 같은 문제가 있었지만 Timwi제안한 대로 사용자 정의 도구 실행 명령을 사용하면 도움이되지 않습니다.

나는에 결국 때문에 그것은 올바른 방향으로 나를 이끌어 속성된 .resx 파일. 여기서 문제가없는 다른 .resx 파일과 의 차이점을 발견했습니다 .

제 경우에는 "Build Action"속성을 "Resource"에서 "Embedded Resource"로 변경해야했습니다.

이유에 대한 가장 좋은 추측 은 다른 응용 프로그램에서 사용 된 라이브러리에 .resx 가 있다는 것 입니다. 내 응용 프로그램에는 자체 .resx 파일이 없으므로 라이브러리의 파일을 사용해야했습니다. 라이브러리에 포함되어 있고 "독립"상태가 아닌 경우에만 사용할 수 있습니다.


비슷한 문제로 Vs 2012에서 실행하면 resx 파일의 "Custom Tool Namespace"속성이 잘못되었습니다 (제 경우에는 실제로 설정되지 않았으므로 생성 된 코드는 런타임 에이 예외를 무시합니다) . resx 파일의 최종 속성 세트는 다음과 같습니다.

  • 빌드 조치 : 임베디드 자원
  • 출력 디렉토리로 복사 : 복사하지 마십시오
  • 사용자 정의 도구 : ResXFileCodeGenerator
  • 사용자 지정 도구 네임 스페이스 : My.Project.S.Proper.Namespace

MSBuild로 빌드 한 후 테스트를 실행할 때 MissingManifestResourceException 참조 (.mresource에 매니페스트에 경로가 있음)

나는 완전성을 위해 여기에 답을 반복합니다.

프로젝트 파일에 LogicalName을 추가하면 수정됩니다.

<LogicalName>$(RootNamespace).Properties.Resources.resources</LogicalName> 

즉, 프로젝트 파일에 포함 된 리소스 항목은 다음과 같습니다.

<ItemGroup>
  <EmbeddedResource Include="Properties\Resources.resx">
    <Generator>ResXFileCodeGenerator</Generator>
    <LastGenOutput>Resources.Designer.cs</LastGenOutput>
    <LogicalName>$(RootNamespace).Properties.Resources.resources</LogicalName> 
  </EmbeddedResource>
</ItemGroup>

자세한 내용은 http://blogs.msdn.com/b/msbuild/archive/2007/10/19/manifest-resource-names-changed-for-resources-files.aspx에 나와 있습니다.

우리는 .resx 파일을 사용하고 있지만 버그는 여전히 발생하는 것으로 보입니다.

Update: The problem with resources (incl. XAML) appears to be related to output paths and the use of forward or backward slashes as detailed in: Why does modifying project output directories cause: IOException was unhandled "Cannot locate resource 'app.xaml'."


I ran into a different cause of this problem, which was unrelated to resx files. I had a class library where AssemblyInfo.cs contained the following:

[assembly: ThemeInfo(
ResourceDictionaryLocation.SourceAssembly,
ResourceDictionaryLocation.SourceAssembly)]

The assembly did not contain any WPF code, theme or Resource dictionaries. I got rid of the exception by removing the ThemeInfo attribute.

I did not get an actual exception, only

A first chance exception of type 'System.Resources.MissingManifestResourceException'.

Viewing exception details, the system was requesting MyAssembly.g.resources

Hope this might be of help to someone else.


Not sure it will help people but this one worked for me :

So the issue I had was that I was getting the following message:

Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "My.Resources.Resources.resources" was correctly embedded or linked into assembly "X" at compile time, or that all the satellite assemblies required are loadable and fully signed"

I was trying to get the resources that were embedded in my project from another class library.

What I did to fix the problem was to set the Access Modifier in the tab Project->Properties->Resources from "Internal" (accessible only within the same class library) to "Public" (accessible from another class library)

Then run and voilà, no more error for me...


The solution given by BlaM worked for me too.

I am a VS 2013 User. After going through many fixes but no luck, I tried this:

  1. Right-click the resource file, one-by-one, in case of multiple-files.
  2. Make sure, the property "Build Action" is set to "Embedded Resource".

That's it! :)


I had the same issue, but in my case i places a class in a usercontrol which is related to the usercontrol like this

Public Class MyUserControlObject

end Class

Public Class MyUserCOntrol

end Class

The solution was to move the MyUserControlObject to the end of the Usercontrol class, like this

Public Class MyUserCOntrol

end Class

Public Class MyUserControlObject

end Class

I hope this helps


I was getting the MissingManifestResourceException error after I ported my project from VS2005 to VS2010. I didn't have any other classes defined in the file that contains my Form class. And I also had my resx Resource File Name set correctly. Didn't work.

So I deleted the resx files and regenerated them. All good now.


Recently ran into the same problem, struggled for a bit, found this topic but no answers were correct for me.

My issue was that when I removed main window from my WPF project (it does not have a main window), I forgot to remove StartupUri from App.xaml. I guess this exception can happen if you have a mistake in StartupUri, so in case if anybody is struggling with this - check your StartupUri in App.xaml.


Recently stumbled upon this issue, in my case I did a few things:

  1. Make sure the namespaces are consistent in the Designer.cs file of the resx file

  2. Make sure the default namespace of the Assembly(right click the project and choose Properties) is set the same to the namespace the resources file is in.

Once I did step 2, the exception went away.


Because I am pre-compiling my web application (using VS2012 publish feature). I was getting the error above. I tried all the suggestions, but weirdly changing 'Build Action' to 'Content' did the trick!


In my case, I have a web api with resources and I create a nuget package from that. When I use this nuget in other projects, I realise that when I request a api with resources, I am getting MissingManifestResourceException after a bit reasearch, I learn nuget packager is not packing resources automatically. If you want to use resources files, you have to do that manually. So you need to add below lines to your .nuspec file: (Visit https://github.com/NuGet/Home/issues/1482)

<package> 
    <metadata>
    </metadata>
    <files>
        <file src="bin\Debug\en\MyAssembly.resource.dll" target="lib\net40\en\MyAssembly.resource.dll" />
        <file src="bin\Debug\es\MyAssembly.resource.dll" target="lib\net40\es\MyAssembly.resource.dll" />
    </files>
</package>

But, before adding files, you need to be sure which version of .net you are using.


I had the with a newly created F# project. The solution was to uncheck "Use standard resource names" in the project properties -> Application -> Resources / Specify how application resources will be managed. If you do not see the checkbox then update your Visual Studio! I have 15.6.7 installed. In 15.3.2 this checkbox is not there.


I had this problem when I added another class in the file just before the class which derived from Form. Adding it after fixed the problem.


Just to mention. If you use a constant or literal, make sure it refers to a resource of the form ProjectName.Resources, and does not cpntain Resources.resx.

It could save you an hour or two .


I've encountered this issue with managed C++ project based on WinForms after renaming global namespace (not manually, but with Rename tool of VS2017).

The solution is simple, but isn't mentioned elsewhere.

You have to change RootNamespace entry in vcxproj-file to match the C++ namespace.


From the Microsoft support page:

This problem occurs if you use a localized resource that exists in a satellite assembly that you created by using a .resources file that has an inappropriate file name. This problem typically occurs if you manually create a satellite assembly.

To work around this problem, specify the file name of the .resources file when you run Resgen.exe. While you specify the file name of the .resources file, make sure that the file name starts with the namespace name of your application. For example, run the following command at the Microsoft Visual Studio .NET command prompt to create a .resources file that has the namespace name of your application at the beginning of the file name:

Resgen strings.CultureIdentifier.resx 
MyApp.strings.CultureIdentifier.resources

참고URL : https://stackoverflow.com/questions/1327692/what-does-missingmanifestresourceexception-mean-and-how-to-fix-it

반응형