Resource file not linked to the assembly error
Hi,
I created a C# class library and added a .resx file. When I tried to access
the values in the resource file, after compiling it I get the following error.
It looks like the resource file is not linked to the assembly. What am I
missing?
Error:
An unhandled exception of type 'System.Resources.MissingManifestResourceException'
occurred in mscorlib.dll
Additional information: Could not find any resources appropriate for the
specified culture (or the neutral culture) in the given assembly. Make sure
"Testapp.resources" was correctly embedded or linked into assembly "Testapp".
baseName: Testapp locationInfo: <null> resource file name: Testapp.resources
assembly: Testapp, Version=1.0.755.20778, Culture=neutral, PublicKeyToken=e79471838db4c67b
Thanks in advance.
Sash
Re: Resource file not linked to the assembly error
You have to ensure the generated .resource filename includes the full
namespace.
So if your code is...
namespace Test
{
class XXX
{
public XXX()
{
ResourceManager rm = new ResourceManager(typeof(XXX));
Bitmap bm = (Bitmap)rm.GetObject("MyBitmap");
}
}
}
then your resx file which has a name of XXX.resx needs to called
Test.XXX.resources when placed inside the assembly. So...
resgen XXX.resx Test.XXX.resources
... then place Test.XXX.resources into the assembly.
"Sash" <sashgeorge@yahoo.com> wrote in message news:3c51fa4d$1@10.1.10.29...
>
> Hi,
>
> I created a C# class library and added a .resx file. When I tried to
access
> the values in the resource file, after compiling it I get the following
error.
> It looks like the resource file is not linked to the assembly. What am I
> missing?
>
> Error:
> An unhandled exception of type
'System.Resources.MissingManifestResourceException'
> occurred in mscorlib.dll
>
> Additional information: Could not find any resources appropriate for the
> specified culture (or the neutral culture) in the given assembly. Make
sure
> "Testapp.resources" was correctly embedded or linked into assembly
"Testapp".
> baseName: Testapp locationInfo: <null> resource file name:
Testapp.resources
> assembly: Testapp, Version=1.0.755.20778, Culture=neutral,
PublicKeyToken=e79471838db4c67b
>
> Thanks in advance.
>
> Sash
>