开发者

List resources in the current project

From a form loaded from a UITypeEditor, how do I get a list of resources in the current project?

I've tried using GetManifestResourceNames() but that gives me a list of resources for the project the user control was created in, instead of the a list of resources in the projected I'm using the开发者_Python百科 user control in.

I'm guessing I need to be able to get the the assembly name of the project in which the root container resides so that I can create the correct resource manager?


If you want to get the assembly that a class of a given instance belongs to, try the following

 Assembly a = Assembly.GetAssembly(instance.GetType());

If you know the type, simply do this

 Assembly a = Assembly.GetAssembly(typeof(MyUserControl));

Or, you can try this, in your user control

 Assembly a = Assembly.GetCallingAssembly();

The last example will return the Assembly of the method that invoked the currently executing method. Perhaps you could store an Assembly reference as a member variable in your UserControl and assign it in your UserControl's constructor. That would give you a reference to the assembly that instantiates your UserControl

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜