c# - Assembly.GetTypes() does not return types that implement an interface defined elsewhere -


i working create list of implementations of specific interface in application , i'm trying reflection in t4 template, using generate c#.

i have code looks this:

<#@ assembly name="$(solutiondir)\..\project2\bin\project1.dll" #> <#@ assembly name="$(solutiondir)\..\project2\bin\project2.dll" #> <#@ import namespace="project1.interfaces" #> <#     string assemblypath1 = this.host.resolvepath("..\\project2\\bin\\project1.dll");     string assemblypath2 = this.host.resolvepath("..\\project2\\bin\\project2.dll");     var type = typeof(project1.interfaces.iaction);     var types1 = assembly.loadfrom(assemblypath1).gettypes()                 .where(p => type.isassignablefrom(p) && p.isclass).tolist();     var types2 = assembly.loadfrom(assemblypath2).gettypes()                 .where(p => type.isassignablefrom(p) && p.isclass).tolist(); #> 

obviously real version lot more , can assume if can't see import directive have omitted here brevity , readability. far can tell problem arises. types1 variable contain list of whole lot of iaction implementations, types2 list empty, in spite of fact have project2 open right in front of me , contains several public types implement iaction .

from can tell looking @ documentation, because iaction interface defined in project1 , there can problems gettypes() related assemblies being loaded when called. however, far can tell actual call running smoothly- i'm not seeing reflectiontypeloadexception being thrown - not find interface implementations. if list names of returned in types2 collection, class names absent list.

what need in order able find implementations of iaction interface in second assembly?

following comments hans passant, able resolve problem making sure used copies of dlls belonged in same dependency chain, rather using ones had come different sources ( choosing output folders took them ) @ point implementations of interface showed in collections.

hopefully can runs same problem great answer details more exact process leads problem.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -