Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting a Type Assembly in Windows 8

I'm trying to use MEF in Windows 8.

In order to build up my AssemblyCatalog for the container, I need a reference to the assembly. In the past, I would have just done this:

var catalog = new AssemblyCatalog(typeof(App).Assembly);

Mysteriously, the Assembly property no longer exists on the Type object. Anybody know of a good work around? Is there another way to get the assembly? I could load it using Assembly.Load, but I would need the name of the assembly. I can't get that from the type either.

Is using a DirectoryCatalog a possible alternate? I don't like the idea, but I'll do what I need to.

like image 263
Josh G Avatar asked Sep 30 '11 14:09

Josh G


2 Answers

using System.Reflection;

Use type.GetTypeInfo().Assembly instead.

like image 116
Roman Boiko Avatar answered Oct 14 '22 22:10

Roman Boiko


Found the answer after some digging through the loads of documentation on building metro style apps.

http://msdn.microsoft.com/en-us/library/windows/apps/br230302%28v=VS.85%29.aspx#reflection

The reflection aspects of the Type class have been moved to a new object called System.Reflection.TypeInfo. You can get an instance of this class by calling type.GetTypeInfo().

So to get the Assembly: typeof(App).GetTypeInfo().Assembly.

Requires using System.Reflection;

like image 34
Josh G Avatar answered Oct 14 '22 22:10

Josh G