MEF从不调用OnImportsSatisfied [英] MEF never calls OnImportsSatisfied

查看:176
本文介绍了MEF从不调用OnImportsSatisfied的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我无法使用MEF在我的IDE中实现编程语言包。

I am having trouble using MEF to implement programming language packages into my IDE.

我看不到我做错了什么 - 我有我的包继承我的接口,继承接口的类使用正确的合同名称导出自己。 

I can't see what I'm doing wrong - I have my interfaces that my packages inherit, and the classes that inherit the interfaces export themselves using the correct contract names. 

我有两个CompositionContainers - 一个我在我的Program类中使用,用于查找对话框窗口扩展,以及我在用于语言包的CompositionInitializer类中使用的扩展。第一个CompositionContainer还加载了应该由第二个加载和使用的
程序集,并为它们创建部件 - 这可能是问题吗?

I have two CompositionContainers - one that I use in my Program class that is used to find dialog window extensions, and one that I use in my CompositionInitializer class that is used for the language packages. The first CompositionContainer also loads the assemblies that are supposed to be loaded and used by the second one, and creates parts for them - could this be the problem?

你的文件想看看如下:

http://code.google.com/p/moonlite-map-studio/source/browse/trunk/moonlite-map-studio/Moonlite/Program.cs

http://code.google.com/p/moonlite-map-studio/source/browse/trunk/moonlite-map-studio/Moonlite/Shell.cs

http: //code.google.com/p/moonlite-map-studio/source/browse/#svn/trunk/moonlite-map-studio/Moonlite.Languages.DynamicLoading   -
即包含动态语言包加载的整个项目。

http://code.google.com/p/moonlite-map-studio/source/browse/#svn/trunk/moonlite-map-studio/Moonlite.Languages.DynamicLoading - that is the whole project that contains the dynamic language package loading.

语言包.dll:

http://code.google.com/p/moonlite-map -studio / source / browse / #svn / trunk / moonlite-map-studio / Moonlite.Languages.Packages.Andromeda

http://code.google.com/p/moonlite -map-studio / source / browse / #svn / trunk / moonlite-map-studio / Moonlite.Languages.Packages.vJass

感谢任何帮助。

谢谢,

Theo

推荐答案

检查MEF codeplex示例:  http://mef.codeplex.com/SourceControl/changeset/查看/ 34058#484669

 


    public virtual void OnImportsSatisfied()
    {
      if (!IsInitialized)
      {
        IsInitialized = true;
        this.CellWidth = Dimensions.CellWidth;
        this.CellHeight = Dimensions.CellHeight;
        this.X = Dimensions.StartShapeX + EnvironmentShape.X;
        this.Y = Dimensions.StartShapeY + EnvironmentShape.Y;
      }
    }


这篇关于MEF从不调用OnImportsSatisfied的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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