[英]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.