我开发了一个应用程序,它使用MEF将所有可用的UserControls显示在窗体上。用户控件和表单都驻留在同一个程序集中。这一切工作正常,当我从XP启动exe,但在使用Windows 7机器时抛出异常。有没有解决这个问题的建议。Windows 7上的MEF异常
0
A
回答
0
嗨,
我把这个整理出来。我在应用程序中使用Log4Net,出于一些奇怪的原因,Winforms的安装应用程序没有使用log4not xml文件。这在安装的版本中缺少,这就是应用程序出现错误的原因。
感谢您的回复。
1
我的第一个建议是展示你的构图方法和一些代码示例。否则,我会消除除了一个UserControl
之外的所有负载。从那里开始。请确保您:
[Export(typeof(IUserControl))]
public class myUserControl : UserControl, IUserControl
{
...
/*
* control to be exported:
* note: you can forego IUserControl and just use UserControl
* but make sure you do so throughout the import and
* export attributes.
*/
...
}
...然后在主机应用:
[ImportMany(typeof(IUserControl))]
IEnumerable<IUserControl> UserControls {get;}
我使用的IEnumerable做为一个例子,因为你期望的负载几个用户控件。我假设你将加载控件以便一次显示。否则,如果你不想让他们一下子,而是需求,我仍然会列举这样:
[ImportMany(typeof(IUserControl))]
IEnumerable<Lazy<IUserControl>> UserControls {get;}
这样你可以遍历,对空测试UserControls[index].Value
。
没有更多的信息,这真的是我能为你做的最好的。
相关问题
- 1. 异常在Windows 7
- 2. 通过皮普在Windows 7上安装Ansible获取ValueError异常
- 3. 必须设置MEF异常“'SourceProvider'”。
- 4. 虚拟机:Ubuntu 7上的Windows 7或Windows 7上的Ubuntu 11?
- 5. 的Windows 7服务差异
- 6. 当在服务器上托管MEF异常
- 7. Windows Server 2016上的Stackoverflow异常(0xc00000fd)
- 8. Windows主机上的安全异常
- 9. 异常在Windows
- 10. Hadoop:Filenotfound异常 - windows
- 11. 上WAMP/Windows 7的
- 12. Windows 7本地主机上的Selenium远程Webdriver抛出空指针异常
- 13. 阅读在Windows注册表7的行为出现异常
- 14. Windows 7 .net Excel .SaveAs()来自HRESULT的错误异常:0x800A03EC
- 15. 的Windows Phone 7如何获得isolatedStorageFileStream.name(抛出异常......)
- 16. InvalidOperationException异常而在Windows Phone的消费WCF Web服务7
- 17. Windows 7中的跨线程异常不太严格
- 18. IIS 7 UrlReferrer抛出异常
- 19. 与NO_MODIFICATION_ALLOWED_ERR DOM异常7
- 20. NIO Files.createTempDirectory在Windows上引起异常
- 21. Windows服务异常
- 22. IoVolumeDeviceToDosName craches Windows 7但在Windows XP上正常工作
- 23. C#WMI Eventwatcher代码在Windows 7上停止工作,出现安全异常
- 24. 异常进口ADT插件在Windows 7 32位
- 25. Word文档。关闭和线程中止异常Windows 7
- 26. Windows 7上的Crystal报告
- 27. Windows 7上的System.Data.OracleClient 64位
- 28. interbase和Windows 7上的BDE
- 29. windows phone 7上的XML
- 30. Windows 7上的AD LDS
我们需要一些代码或示例,以及明确的错误信息。 – IAbstract 2010-12-17 01:36:35