检测本机.NET类型 [英] Detecting native .NET types

查看:55
本文介绍了检测本机.NET类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


有没有人知道是否有一种(简单的)方法来检测是否有任意的b。b系统类型。源于与用户定义的

程序集相对的.NET框架。谢谢。

Hi there,

Does anyone know if there''s a (simple) way to detect whether an arbitrary
"System.Type" originates from the .NET framework opposed to a user-defined
assembly. Thanks.

推荐答案

2008年7月21日星期一16:05:20 -0700,John W.< no_spam@_nospam.comwrote:
On Mon, 21 Jul 2008 16:05:20 -0700, John W. <no_spam@_nospam.comwrote:

你好,


有没有人知道是否有(简单)方法来检测是否有任意的

" System.Type"源于.NET框架,而不是用于
用户定义的
程序集。谢谢。
Hi there,

Does anyone know if there''s a (simple) way to detect whether an arbitrary
"System.Type" originates from the .NET framework opposed to a
user-defined
assembly. Thanks.



定义.NET Framework。你的意思是CLR吗?或者你的意思是

包括微软作为.NET的一部分提供的任何程序集?


我不知道是否有规范机制用于识别类型为

..NET或不是,但是不应该太难以追踪所有

的名称你认为属于的组件.NET,然后查看

System.Type.Assembly属性,看看有问题的类型是否来自

其中一个程序集。


Pete

Define ".NET Framework". Do you mean just the CLR? Or do you mean to
include any assembly provided by Microsoft as part of .NET?

I don''t know if there''s a canonical mechanism for identifying types as
..NET or not, but it shouldn''t be too hard to track down the names of all
the assemblies you consider to be part of .NET, and then look at the
System.Type.Assembly property to see if the type in question comes from
one of those assemblies.

Pete


感谢您的反馈...
Thanks for the feedback ...

define" .NET框架" ;.你的意思是CLR吗?或者你的意思是

包括微软作为.NET的一部分提供的任何程序集?
Define ".NET Framework". Do you mean just the CLR? Or do you mean to
include any assembly provided by Microsoft as part of .NET?



是的,CLR - 随框架安装程序安装的任何东西。

Yes, the CLR - anything that''s installed with the framework installer.


我不喜欢我不知道是否有一种识别类型的规范机制

.NET或者不是
I don''t know if there''s a canonical mechanism for identifying types as
.NET or not



你可能是对的。我希望可能有办法...


,但是要追踪所有
的名称并不是太难了

You''re probably right. I was hoping there might be a way ...

, but it shouldn''t be too hard to track down the names of all


您认为属于.NET的程序集,然后查看

System.Type.Assembly属性以查看相关类型是否来自

其中一个集会。
the assemblies you consider to be part of .NET, and then look at the
System.Type.Assembly property to see if the type in question comes from
one of those assemblies.



我也希望尽可能避免这条路线。我的应用程序将在2.0或更高版本上处理

任意类型,我需要区分

用户定义类型和本机.NET类型。我不想跟踪2.0和3.X中所有组件的价值。如果有一种方法可以动态地确定动态,那将会更清晰。

I was also hoping to avoid this route if possible. My app will be processing
arbitrary types on 2.0 or later and I need to distinguish between
user-defined types and native .NET types. I didn''t want to have to track
down all assemblies in 2.0 and 3.X. It would be cleaner if there was a way
to dynamically determine things on-the-fly.


2008年7月21日星期一16: 40:59 -0700,John W.< no_spam@_nospam.comwrote:
On Mon, 21 Jul 2008 16:40:59 -0700, John W. <no_spam@_nospam.comwrote:

感谢您的反馈...
Thanks for the feedback ...

>定义.NET Framework。你的意思是CLR吗?或者你的意思是包括微软作为.NET的一部分提供的任何程序集?
>Define ".NET Framework". Do you mean just the CLR? Or do you mean to
include any assembly provided by Microsoft as part of .NET?



是的,CLR - 随框架安装程序一起安装的任何东西。


Yes, the CLR - anything that''s installed with the framework installer.



所有应有的尊重,这是一个不一致的答案。 CLR只是

运行时(mscorlib.dll)。 .NET Framework包含更多内容。

.NET的不同部分可以在不同的程序集中找到。


我的答案是_all_ of .NET ,而不仅仅是CLR(后者

会更容易......只需寻找一个DLL)。

All due respect, that''s an inconsistent answer. The CLR is just the
run-time (mscorlib.dll). The .NET Framework includes more than that.
Different parts of .NET are found in different assemblies.

I take your answer to mean _all_ of .NET, not just the CLR (the latter
would be easier...just look for the one DLL).


[... ]

我也希望尽可能避免这条路线。我的应用程序将是

处理

在2.0或更高版本上的任意类型我需要区分

用户定义类型和本机.NET类型。
[...]
I was also hoping to avoid this route if possible. My app will be
processing
arbitrary types on 2.0 or later and I need to distinguish between
user-defined types and native .NET types.



我很好奇为什么,如果你不介意分享。在我看来,这是一个有点随意的要求,因为这些类型在其他情况下表现完全相同。什么是.NET类型与第三方类型

使它们如此不同以至于您需要独立跟踪它们?


我不是知道。也许其他人会有更好的建议,如何确定来自.NET的所有类型,或者如何
自动确定一个完整的程序集列表组成

..NET(我觉得这是一个合理的选择)。但是面对它,如果是我的话,我会努力重新定义问题,这样就可以更轻松了。 :)


Pete

I''m curious as to why, if you don''t mind sharing. It seems to me to be a
somewhat arbitrary requirement, since the types would otherwise behave
exactly the same. What is it about .NET types versus third-party types
that makes them so different that you need to track them independently?

I don''t know. Maybe someone else will have better advice as to how to
identify all of the types that come from .NET, or alternatively how to
automatically determine a complete list of the assemblies that make up
..NET (I figure that would be a reasonable alternative). But on the face
of it, if it were me, I''d be working to redefine the problem so that it''s
easier. :)

Pete


这篇关于检测本机.NET类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆