Windows 7 上的 MEF 异常
我开发了一个应用程序,它使用 MEF 来获取可在表单上显示的所有用户控件。用户控件和窗体都驻留在同一个程序集中。当我从 XP 启动 exe 时,一切正常,但在使用 Windows 7 机器时抛出异常。有什么建议可以解决这个问题吗?
I have developed an application that uses MEF to get all the UserControls available to be shown on a form. The user controls and the form both reside in the same assembly. This all works fine when I launch the exe from XP, but throw exception when using Windows 7 machine. Is there any suggestion to solve this issue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的第一个建议是展示你的组合方法和一些代码示例。否则,我将消除除一个
UserControl
之外的所有负载。从那里开始。确保您:...然后在 Host 应用程序中:
我在这里使用 IEnumerable 作为示例,因为您希望加载多个 UserControl。我假设您将立即加载要显示的控件。否则,如果您不想一次性全部使用它们,而是按需,我仍然会这样枚举:
这样您就可以迭代、测试
UserControls[index].Value为空。
如果没有更多信息,这确实是我能为您做的最好的事情。
My first suggestion is to show your method of composition and some code examples. Otherwise, I would eliminate all the loads except one
UserControl
. Start from there. Make sure that you:...and then in the Host app:
I am using IEnumerable here as an example because you are expecting load several UserControls. I am assuming that you will be loading the controls to be displayed at once. Otherwise, if you don't want them all at once, but rather on demand, I would still enumerate as such:
This way you can iterate, test
UserControls[index].Value
for null.Without more information, this is really the best I can do for you.
嗨,
我已经解决了这个问题。我在应用程序中使用 Log4Net,由于一些奇怪的原因,Winforms 的安装应用程序没有采用 log4not xml 文件。安装的版本中缺少此功能,这就是应用程序出错的原因。
感谢您的回复。
HI,
I got this sorted out. I was using Log4Net in the application and for some strange reasons, the setup application for the Winforms was not taking the log4not xml file. This was missing in the installed version and this was the reason of the application being getting errored out.
Thanks for your replies.