2015-05-05 48 views
0

我無法在安裝過程中排除一些裝配。在Windsor Castle登記之前如何排除裝配

我試試這個:

public class InternationnalisationInstaller : IWindsorInstaller 
{ 
    public void Install(Castle.Windsor.IWindsorContainer container, Castle.MicroKernel.SubSystems.Configuration.IConfigurationStore store) 
    { 
     string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) 
     var filter = new AssemblyFilter(path) 
       .FilterByAssembly(a => !a.IsDynamic 
        && !a.FullName.Contains("Microsoft")); 

     container.Register(Classes.FromAssemblyInDirectory(filter) 
      .BasedOn<ITraductionProvider>()    
      .WithService.AllInterfaces()); 
    } 
} 

在開發中沒有問題,但在生產中:

不可能去充電器樂fichier OU L'集「Microsoft.VisualStudio.Shell.Immutable.10.0,版本= 10.0.0.0,文化=中立,PublicKeyToken = b03f5f7f11d50a3a'ou une de sesdépendances。 Le fichierspécifiéest introuvable。 àSystem.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly組件,ObjectHandleOnStack retTypes) àSystem.Reflection.RuntimeAssembly.GetExportedTypes() àCastle.Core.Internal.ReflectionUtil.GetAvailableTypes(大會組件,布爾includeNonExported) àCastle.Core .Internal.ReflectionUtil.GetAvailableTypesOrdered(Assembly assembly,Boolean includeNonExported) àCastle.MicroKernel.Registration.FromAssemblyDescriptor.b__0(Assembly a) àSystem.Linq.Enumerable.d__14 2.MoveNext() àCastle.MicroKernel.Registration。 FromDescriptor.Castle.MicroKernel.Registration.IRegistration.Register(IKernelInternal kernel) àCastle.MicroKernel.Registration.BasedOnDescriptor.Castle.MicroKernel.Registration.IRegistration.Register(IKerne lInternal內核) àCastle.MicroKernel.DefaultKernel.Register(IRegistration []註冊) àCastle.Windsor.WindsorContainer.Register(IRegistration []註冊) àInternationnalisation.InternationnalisationInstaller.Install(IWindsorContainer容器,IConfigurationStore存儲)

該程序集用於標記VSIX註冊的類。 你能幫我嗎? 謝謝

+0

如果需要,也許只是不排除它? – Jester

+0

你能把錯誤信息翻譯成英文嗎? –

+0

Sriram:FileNotFoundException – Dekey

回答

0

這裏是一個應用程序的例子,我明確加載我的程序集以進行集成測試。無論你想要什麼,你都可以添加/編輯這個LINQ to Entiteis查詢。 :

DirectoryInfo areasFolder = new DirectoryInfo(HostingEnvironment.MapPath(@"~\Areas")); 
FileInfo[] assemblyFiles = 
         areasFolder.EnumerateDirectories() 
          .SelectMany(d => d.EnumerateFiles("*.dll")) 
          .Where(f => f.Name.Contains("MyAppNamespace")) 
          .GroupBy(f => f.Name.Substring(0, f.Name.Length - f.Extension.Length)) 
          .Select(g => g.OrderByDescending(f => f.LastWriteTimeUtc).First()) 
          .ToArray();