Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 获取Windows 8.1通用应用程序引用程序集中的所有类_C#_.net_Windows 8.1_Windows Phone 8.1_.net Assembly - Fatal编程技术网

C# 获取Windows 8.1通用应用程序引用程序集中的所有类

C# 获取Windows 8.1通用应用程序引用程序集中的所有类,c#,.net,windows-8.1,windows-phone-8.1,.net-assembly,C#,.net,Windows 8.1,Windows Phone 8.1,.net Assembly,我有一个项目,我正在从WindowsPhone8迁移到通用Windows8.1 脚本 在解决方案中,我有多个程序集,这些程序集实现了在公共程序集中定义的接口(但不是每个程序集中的所有程序集,它们各不相同),但所有程序集都实现或扩展了接口IResolver 我在“main”项目/程序集中使用反射来注册引用程序集中的类,方法是将该程序集的IResolver(接口)实现的实例传递给它 代码 它就像一个符咒:——) 问题 System.Type不包含Assembly的定义,并且找不到接受类型为Syste

我有一个项目,我正在从WindowsPhone8迁移到通用Windows8.1

脚本 在解决方案中,我有多个程序集,这些程序集实现了在公共程序集中定义的接口(但不是每个程序集中的所有程序集,它们各不相同),但所有程序集都实现或扩展了接口
IResolver

我在“main”项目/程序集中使用反射来注册引用程序集中的类,方法是将该程序集的
IResolver
(接口)实现的实例传递给它

代码 它就像一个符咒:——)

问题
System.Type
不包含
Assembly
的定义,并且找不到接受类型为
System.Type
的第一个参数的扩展方法
Assembly

它在文件中指出:

支持:Windows Phone 8.1、Windows Phone Silverlight 8.1、Windows Phone Silverlight 8

因此在Windows 8.1中不受支持,但即使它在Windows Phone 8.1项目中,仍然表示不包含
程序集的定义

如果这还不够,那么类Assemly
不会实现方法
GetTypes()

问题 如何从接口实例获取Universal App的引用程序集中定义的所有类

有什么建议或选择吗

不起作用的事情
错误:
System.Reflection.Assembly
不包含
GetExecutingAssembly

的定义好吧,这很烦人

GetType().GetTypeInfo()


嗯,这很烦人

GetType().GetTypeInfo()


我认为这是同样的问题:谢谢@KooKiz。是的,我看也差不多。不管怎样,我还是解决了这个问题,花了这么多时间:呵呵。我想这是同一个问题:谢谢@KooKiz。是的,我看也差不多。不管怎样,我还是解决了它,花了这么多时间:呵呵。
using System.Reflection;
...
public void Register(IResolver resolver)
{
   foreach (Type classType in resolver.GetType().Assembly.GetTypes())
   {
      // Register the class type with the ioc container
   }
}
Assembly.GetExecutingAssembly()
public void Register(IResolver resolver)
{
   foreach (Type classType in resolver.GetType().GetTypeInfo().Assembly.GetExportedTypes())
   {
      // Register the class type with the ioc container
   }
}