English 中文(简体)
未发现的ms粒类型
原标题:Type from mscorlib not found

我无法理解。 我可以读到哪类参考资料:

Assembly mscorlib = Assembly.Load("mscorlib");

// it DOES exist, returns type reference:
mscorlib.GetType("System.Deployment.Internal.Isolation.IDefinitionAppId");

// but its parent scope doesn t exist.. returns null:
mscorlib.GetType("System.Deployment.Internal.Isolation"); 

// even though it exists, it doesn t compile
// System.Deployment.Internal.Isolation.IDefinitionAppId x;

如何做到这一点?

最佳回答

您最后一行的汇编是以下原因:IDefinitionAppIdinternal——不是因为System.Dending.Internal.Isolation是一类。

请注意,如果<代码>Isolation 是某一种类型的名称,则您必须使用GetType(“System.Dending.Internal.Isolation+IDefinitionAppId”(注+),因为申述类型如何在《航天中心名称》中体现。

证明这一点非常简单:

using System;
using System.Reflection;

public class Test
{
    static void Main()
    {
        Assembly mscorlib = typeof(string).Assembly;
        string name = "System.Deployment.Internal.Isolation.IDefinitionAppId";
        Type type = mscorlib.GetType(name);

        // Prints System.Deployment.Internal.Isolation
        Console.WriteLine(type.Namespace);
    }
}

因此,<代码> 大会:GetType(......)t 认为它是一种类型。

问题回答

系统部署:内部解体是一个名称空间,而不是一种类型,你可以“参考”一个名称空间,它只是整个类别名称的一部分。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签