简体   繁体   English

Windows phone 8.1 Assembly.GetExecutingAssembly不可用

[英]Windows phone 8.1 Assembly.GetExecutingAssembly not available

I am using reflection to register default instances for inversion of control. 我使用反射来注册控制反转的默认实例。 I need to scan all loaded assemblies and then iterate through each type and register. 我需要扫描所有已加载的程序集,然后遍历每个类型并注册。 The problem is that in my visual studio code file I do not have the method Assembly.GetExecutingAssembly() or any other methods that I would normally expect. 问题是,在我的visual studio代码文件中,我没有方法Assembly.GetExecutingAssembly()或我通常期望的任何其他方法。

Why is this happening. 为什么会这样呢? My code should look like this: 我的代码应如下所示:

foreach (var type in (Assembly.GetExecutingAssembly().GetTypes())
{
    if (type.IsClass && !type.IsAbstract)
    {
       //registers the type for an interface it implements
    }
}

你不能像你发现的那样在WinRT中执行程序集 - 但你可以输入“你的程序集” - typeof(AnyTypeInYourAssembly).GetTypeInfo().Assembly

I researched into this more, and it turns out the problem lies in the fact that Windows Phone 8.1 applications have the same restrictions as WinRT applications. 我对此进行了更多的研究,结果发现问题在于Windows Phone 8.1应用程序与WinRT应用程序具有相同的限制。 There is no GetExecutingAssembly method for WinRT runtime. WinRT运行时没有GetExecutingAssembly方法。

You are forced with workarounds. 你被迫使用变通办法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么 Assembly.GetExecutingAssembly() 会返回 null? - Why would Assembly.GetExecutingAssembly() return null? 使用Assembly.GetExecutingAssembly()从其他类库获取程序集 - Use Assembly.GetExecutingAssembly() to get assembly from other class library Assembly.GetExecutingAssembly()和typeof(程序)之间的区别.Assembly - Difference between Assembly.GetExecutingAssembly() and typeof(program).Assembly Assembly.GetExecutingAssembly()。CreateInstance应该在这里抛出异常吗? - should Assembly.GetExecutingAssembly().CreateInstance throw an exception here? VS 2010构建输出路径是否覆盖Assembly.GetExecutingAssembly案例? - VS 2010 Build Output path overrides Assembly.GetExecutingAssembly case? Fody 和 Assembly.GetExecutingAssembly().Location 返回空字符串 - Fody and Assembly.GetExecutingAssembly().Location returns empty string 与 C# 中的 Assembly.GetExecutingAssembly().GetTypes() 相关的问题 - Issue Related to Assembly.GetExecutingAssembly().GetTypes() in C# NUnit运行多个程序集时Assembly.GetExecutingAssembly的意外位置 - Unexpected Location of Assembly.GetExecutingAssembly When NUnit Runs Multiple Assemblies 这个.GetType()。Assembly.GetName()。版本和Assembly.GetExecutingAssembly()。GetName()。版本有什么区别? - What's the difference between this.GetType().Assembly.GetName().Version and Assembly.GetExecutingAssembly().GetName().Version? Assembly.GetExecutingAssembly()。GetManifestResourceNames()是否从App_LocalResources返回资源? - Does Assembly.GetExecutingAssembly().GetManifestResourceNames() return resources from App_LocalResources?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM