2011-09-20 63 views
0

我嘗試下面的鏈接與MEF窗口申請MEF for framework 3.5和MEFfor framework 4.0的基本不同之處是什麼?

http://geekswithblogs.net/malisancube/archive/2009/05/26/managed-extensibility-framework-101---a.aspx

它在Framework 3.5的工作很好,但是當我嘗試開發相同的代碼框架4.0 無法找到以下功能

return container.GetExportedObject<Form1>(); 

請給我一些適當的窗口應用與MEF的例子,其中我的容器上的所有用戶控件的表格

回答

0

MEF正在被de開發了.NET 4.0,但它成爲.NET 4.0轉發框架的官方部分。你正在尋找的API實際上是ExportProvider.GetExportedValue<T>方法從CompositionContainer繼承:

return container.GetExportedValue<Form1>(); 

GetExportedObject更名GetExportedValue,並將其與MEF預覽6,這意味着博客文章實際上是基於相當的早期版本出現MEF。

+0

這不適用於Windows應用程序。它得到空值 –

+0

你能提供你實際使用的代碼嗎? –

相關問題