tags:

views:

345

answers:

3

Hi,

I'm trying to create an instance of ResourceManager:

public ResourceManager(baseName, Assembly assembly)

I know the name of the assembly that the resource is in (it's not the executingassembly), and it's referenced in the project, but how do I specify it here in the code (using the above constructor)?

May be a bit of a stupid question, but I'm a bit stuck!

Thanks!

+2  A: 

You can use the method Assembly.GetAssembly, perhaps:

Assembly.GetAssembly(typeof(SomeClassInTheAssembly));

...or simply pick up the assembly from a known type:

typeof(SomeClassInTheAssembly).Assembly;

Either way, a Type from the given assembly is your key.

Fredrik Mörk
Thanks for answer!
UpTheCreek
+3  A: 

The easiest way to grab an assembly reference is via a type that you know is declared in the assembly. e.g.: typeof(SomeKnownType).Assembly.

Nicole Calinoiu
+1  A: 
Assembly asm = Assembly.GetAssembly(typeof(ClassInThatAssembly));
ResourceManager rm = new ResourceManager("resString",asm);

Did you try this?

ArsenMkrt
No - having a slightly dumb day ;)
UpTheCreek