M
Mike Bresnahan
In my hypothetical C# application I have a class named MyNamespace.MyClass
defined in the file MyNamespace/MyClass.cs and an associated resource
defined in the file MyNamespace/MyClass.resx. Naively I compiled the .resx
file with the following command:
resgen MyNamespace/MyClass.resx
and received the file MyNamespace/MyClass.resources, which I naively
embedded in my application with the following command:
csc /resource:MyNamespace/MyClass.resources MyNamespace/MyClass.cs
When I ran my executable, I received the following error:
System.Resources.MissingManifestResourceException: Could not find any
resources appropriate for the specified culture (or the neutral culture) in
the given assembly. Make sure "MyClass.resources" was correctly embedded or
linked into assembly "MyClass".
baseName: MyClass locationInfo: MyNamespace.MyClass resource file name:
MyClass.resources assembly: MyClass, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null
This error was very confusing, because it appeared to be saying that it
could not find the file MyClass.resources even though I had explicitly named
this file on the command line. After some research and some trial and error
I changed by compile command line to the following:
csc /resource:MyNamespace/MyClass.resources,MyNamespace.MyClass.resources
MyNamespace/MyClass.cs
Note the magic text ",MyNamespace.MyClass.resources". With this change my
problem went away.
I also discovered that if I renamed MyNamespace/MyClass.resources to
MyNamespace/MyNamespace.MyClass.resources and referenced it directly in the
csc command line that my problem went away.
Is this behavior documented anywhere?
Is the error message extremely misleading or am I confused? Shouldn't it
complain that it can't find the resource MyNamespace.MyClass.resources
instead of just MyClass.resources?
Is there an easier way to solve this problem? I should think that resgen
could be smart enough to name .resources files appropriately, but I don't
see a command line option for it. My current solution will require my Ant
script to perform some magic to either rename all the .resources files or
specify the proper ",MyNamespace.MyClass.resources" options to the csc
command.
Mike Bresnahan
defined in the file MyNamespace/MyClass.cs and an associated resource
defined in the file MyNamespace/MyClass.resx. Naively I compiled the .resx
file with the following command:
resgen MyNamespace/MyClass.resx
and received the file MyNamespace/MyClass.resources, which I naively
embedded in my application with the following command:
csc /resource:MyNamespace/MyClass.resources MyNamespace/MyClass.cs
When I ran my executable, I received the following error:
System.Resources.MissingManifestResourceException: Could not find any
resources appropriate for the specified culture (or the neutral culture) in
the given assembly. Make sure "MyClass.resources" was correctly embedded or
linked into assembly "MyClass".
baseName: MyClass locationInfo: MyNamespace.MyClass resource file name:
MyClass.resources assembly: MyClass, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null
This error was very confusing, because it appeared to be saying that it
could not find the file MyClass.resources even though I had explicitly named
this file on the command line. After some research and some trial and error
I changed by compile command line to the following:
csc /resource:MyNamespace/MyClass.resources,MyNamespace.MyClass.resources
MyNamespace/MyClass.cs
Note the magic text ",MyNamespace.MyClass.resources". With this change my
problem went away.
I also discovered that if I renamed MyNamespace/MyClass.resources to
MyNamespace/MyNamespace.MyClass.resources and referenced it directly in the
csc command line that my problem went away.
Is this behavior documented anywhere?
Is the error message extremely misleading or am I confused? Shouldn't it
complain that it can't find the resource MyNamespace.MyClass.resources
instead of just MyClass.resources?
Is there an easier way to solve this problem? I should think that resgen
could be smart enough to name .resources files appropriately, but I don't
see a command line option for it. My current solution will require my Ant
script to perform some magic to either rename all the .resources files or
specify the proper ",MyNamespace.MyClass.resources" options to the csc
command.
Mike Bresnahan