使用反射来遍历所有引用的程序集的类型,在Silverlight?遍历、射来、类型、程序

2023-09-03 17:17:12 作者:柔情痞子

有没有equivilent这在Silverlight?

Is there an equivilent to this in silverlight?

 var assemblies = AppDomain.CurrentDomain.GetAssemblies();

http://msdn.microsoft.com/en-us/library/system.appdomain.getassemblies(v=VS.95).aspx

是否有这样做的另一种方式?

Is there another way of doing this?

下面是关于如何在混合做了设计时间后......但如何在运行时?

Here's a post on how to do it for design time under blend... but how at runtime?

http://joshsmithonwpf.word$p$pss.com/2010/01/06/the-ultimate-hack-for-silverlight-in-blend/

看起来不像这是可能的:

Doesn't look like this is possible:

Getting在Silverlight 3 运行时组件

http://forums.silverlight.net/p/22050/77847.aspx

http://forums.silverlight.net/t/22050.aspx/1?Get+a+list+of+loaded+assemblies

推荐答案

这个问题最初提出的东西等同于 Assembly.GetExecutingAssembly()。GetAvailableTypes()在Silverlight,所以这是我的第一个答案。的

The question originally asked for something equivalent to Assembly.GetExecutingAssembly().GetAvailableTypes() in Silverlight, so that's my first answer.

Silverlight支持反思:

Silverlight supports reflection:

Assembly.GetExecutingAssembly()支持Silverlight中,包括Windows Phone 7和Xbox 360。 Assembly.GetExportedTypes() Assembly.GetTypes()在Silverlight的两个支撑,包括Windows 7和XBOX 360。 Assembly.GetExecutingAssembly() is supported in Silverlight, including Windows Phone 7 and XBox 360. Assembly.GetExportedTypes() and Assembly.GetTypes() are both supported in Silverlight, including Windows 7 and XBox 360.

请参见文档< /一>,然后选择Silverlight的作为版本的详细信息。

See the documentation and select "Silverlight" as the version for details.

AppDomain.CurrentDomain 支持在Silverlight 3和4。 AppDomain.GetAssemblies()支持Silverlight 4中。 AppDomain.CurrentDomain is supported in Silverlight 3 and 4. AppDomain.GetAssemblies() is supported in Silverlight 4.

最简单的是升级,而不必做解决方法的Silverlight 4。

The easiest is to upgrade to Silverlight 4 instead of having to do workarounds.