I have a internal project's binaries. And I am trying to load them and use the methods in them through reflection in another project whenever needed.
But the type I am looking for comes as null in execution context . But whereas when I try to load the same type from reflection only context , its returning proper Type .
Because of this I am not able to execute any methods inside the Dll.
Execution context code:
public Type GetTypeFromDll(string dllPath, string typeName)
{
var assembly = Assembly.LoadFile(dllPath);
var result = assembly.GetType(typeName);
}
ReflectionOnly context:
try
{
Assembly.ReflectionOnlyLoad(assemblyName.FullName);
}
catch
{
Assembly.ReflectionOnlyLoadFrom(Path.Combine(Path.GetDirectoryName(dllPath), assemblyName.Name + ".dll"));
}
Note: This happens with only one of the types in that dll but the other types seems to be loading fine. But when I check the code , these types are almost similar. Not sure what's missing.