UpTheCreek
UpTheCreek

Reputation: 32391

Specifying assembly in ResourceManager constructor (c#/.net)

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!

Upvotes: 0

Views: 2271

Answers (3)

Nicole Calinoiu
Nicole Calinoiu

Reputation: 21002

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.

Upvotes: 3

Arsen Mkrtchyan
Arsen Mkrtchyan

Reputation: 50752

Assembly asm = Assembly.GetAssembly(typeof(ClassInThatAssembly));
ResourceManager rm = new ResourceManager("resString",asm);

Did you try this?

Upvotes: 1

Fredrik Mörk
Fredrik Mörk

Reputation: 158389

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.

Upvotes: 2

Related Questions