0
是否可以在iis託管的wcf服務中通過程序集解析事件加載程序集。我不想通過GAC或bin文件夾加載程序集。可能嗎?謝謝。IIS託管Wcf服務與組裝解決方案是可能的?
是否可以在iis託管的wcf服務中通過程序集解析事件加載程序集。我不想通過GAC或bin文件夾加載程序集。可能嗎?謝謝。IIS託管Wcf服務與組裝解決方案是可能的?
我不認爲你可以使用AppDomain.AssemblyResolve事件,但你可能會嘗試的是using MEF來解決使用DirectoryCatalog的實際實現。所以你的SVC代碼背後(或者你可以刪除後面的代碼,並將你的SVC指向一個單獨的程序集中的類)看起來像這樣(未經測試)。我沒有試過這個特定的方法,但我沒有看到任何理由,它不會工作。
public class YourServiceClass : YourServiceContract
{
[Import]
private IContract Implementation { get; set; }
private DirectoryCatalog _directoryCatalog = null;
private CompositionContainer _container = null;
public YourServiceClass()
{
_directoryCatalog = new DirectoryCatalog(YourDirectoryPathHere);
_container = new CompositionContainer(_directoryCatalog);
_container.ComposeParts(this);
}
//Operation
public void DoSomething()
{
Implementation.DoSomething();
}
}
如果有意義的話,您也可以將MEF代碼移到基類。如果你是MEF的新手,這裏有一個教程using MEF with a DirectoryCatalog。
所以你想實現程序集生活在一個「自定義」位置? – BrandonZeider 2011-04-11 13:01:29
@brandon是自定義位置。 – mkus 2011-04-11 13:33:53