Cortlendt
Cortlendt

Reputation: 2240

WinStore/WinPhone - how can I get runtime Assembly type for assembly I cannot reference at design time

I'm implementing a resource manager. Its interface and implementation are located in Infrastructure assembly. Resources are located in Presentation assembly. Presentation assembly references Infrastructure assembly.

My problem:

ResourceManager rm = new ResourceManager("Strings", typeof(Presentation.SomeType).Assembly);

This code in Infrastructure assembly won't compile, because SomeType is in Presentation assembly and it can't be referenced due to circular dependencies.

What is an optimal way to get Assembly type in this scenario? I can use DI container and move impl to Presentation but I don't want to do this just yet.

PS. I need to write code targeting both WinStore/WinPhone.

Upvotes: 1

Views: 101

Answers (1)

Cortlendt
Cortlendt

Reputation: 2240

Looks like you can use:

var assemblyName = new AssemblyName() {Name = "YouAssemblyNameWithoutExtension"};
var assembly = Assembly.Load(assemblyName);

I've been told loading assemblies like this may pose a problem during certification, so ymmv.

Upvotes: 1

Related Questions