자진 플러그인 아키텍처를 .NET 4.0의 MEF로 변환 중입니다. MEF 기반 응용 프로그램은 내 로컬 컴퓨터에서 실행될 때 멋지게 작동합니다. 그러나 응용 프로그램을 네트워크 공유로 이동 한 다음 응용 프로그램을 실행하면 MEF가 더 이상 내 플러그인을로드하지 않습니다.MEF 기반 응용 프로그램은 로컬 컴퓨터에서 잘 작동하지만 네트워크 공유에서 실행할 때 AddIns를 가져 오지 않습니다.
프로세스에 디버깅 세션을 연결하고 DirectoryCatalog 개체를 검사 할 때 어셈블리 또는 부품 속성에 항목이없는 것을 볼 수 있습니다. FullPath가 올바른 디렉터리이고 LoadFiles 속성은 검색중인 디렉터리에있는 모든 DLL을 포함합니다.
처음에는 CasPol을 수정하려고 시도하고 CasPol이 .NET 4.0에서 더 이상 기본적으로 활성화되어 있지 않다는 경고를받을 때까지 이것이 CasPol 문제라고 생각했습니다. 그것은 다른 것임에 틀림 없다. 나는 해당 디렉토리에 대한 모든 권한을 가지고 있습니다. 여기
가져온 추가 기능을 포함 할 속성입니다 :[ImportMany]
private IEnumerable<IRecipient> RecipientAddIns;
을 그리고 여기 발견하고 추가 기능 가져 오는 방법 :
private void LoadRecipientAddIns()
{
using (var catalog = new AggregateCatalog())
{
// Look for IRecipient AddIns in the ./Recipients directory.
catalog.Catalogs.Add(new DirectoryCatalog("Recipients"));
// Look for IRecipient AddIns in subdirectories hanging off of ./Recipients.
foreach (string currentDirPath in Directory.GetDirectories("Recipients"))
catalog.Catalogs.Add(new DirectoryCatalog(currentDirPath));
using (var compositionContainer = new CompositionContainer(catalog))
{
compositionContainer.ComposeParts();
compositionContainer.SatisfyImportsOnce(this);
// The discovered AddIns should now be in the RecipientAddIns property.
}
// Do stuff with the Recipient AddIns
foreach (var recipient in this.RecipientAddIns)
{
...
}
}
// Clear the list of discovered Recipient AddIns
this.RecipientAddIns = null;
}
어떤 아이디어?
감사합니다.
어셈블리가 Assembly.Load *()에 불만없이로드됩니다. 또한 MEF가 DirectoryCatalog() 기반의 검색을 주석 처리하고'catalog.Catalogs.Add (새 AssemblyCatalog (AppDomain.CurrentDomain.BaseDirectory + "\\ Recipients \\ Recipient1)와 같은 몇 가지 호출을 추가하여 MEF를로드 할 수있었습니다. \\ Recipient1.dll "));'DirectoryCatalog()를 비난하고 싶지만 더 좋고 깨끗하기 때문에 작동시키고 싶습니다. – AndrewP
당신의 제안은 결국 도움이되었습니다! 지난 밤에 테스트 해 보았을 때 네트워크 공유에서 코드를 실행하는 것을 잊어 버렸고 대신 로컬 컴퓨터에서 코드를 실행했습니다. 네트워크에서 동일한 코드를 실행하여 DirectoryCatalog() 비트를 개별 AssemblyCatalog()로 대체 한 경우 NotSupportedException 내부 예외가 발생하여 FileLoadException 예외가 발생했습니다. [MS 기술 자료] (http://go.microsoft.com/fwlink/?LinkId=155569) 해결 방법은 응용 프로그램 구성에' '를 추가하는 것입니다. 고마워, 대니얼. –
AndrewP
원격 소스에서로드가 XP 또는 2k3에서 작동하지 않는 것 같습니다. – user7116