繁体   English   中英

导入但未加载dll

[英]import but dll was not loaded

我有一个导出的类,并且在导入的代码的不同部分中。

[Import]
public IEnumerable<IRTAOperatorErrorNotifications> RTAOperatorErrorNotifications
{
    get { return m_RTAOperatorErrorNotifications; }
}

现在将类驻留的DLL有条件地加载到应用程序中,并且在大多数情况下它不存在,所以我想知道如果DLL不存在,这会导致程序崩溃吗? 我想要的是将该对象简单地设置为null(如果DLL不存在),以便我可以检查并做正确的事情。 有没有一种方法可以有条件地导入,因此如果未加载该类,则将该值设置为null?

谢谢,

建议的更改:由于它是IEnumerable您需要使用ImportMany AllowDefault = true允许代码在未找到导入时将其设置为NULL

[ImportMany(AllowDefault = true)]
public IEnumerable<IRTAOperatorErrorNotifications> RTAOperatorErrorNotifications { get; private set; }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM