I have an application that uses reflection to load a .dll and invoke a method with parameters. reflection module was built using .net 4.5 This has worked for us for years. we have recently tried to use a dll that was built using .net4.7.2 and the reflection module excepts on the invoke call, but the method is not the cause of the exception, as that method has an exception handler that would log the error. that it not even reached, it seems to fail at the moment of invoke.
this is the faulting code ("plugin" here is the .net4.7.2 isolated assembly that has the method to be invoked):
object objRef = null;
using((objRef as IDisposable)) {
objRef = Activator.CreateInstance(plugin.type);
MethodInfo methodToInvoke;
if(plugin.methods[method].Count == 1) {
methodToInvoke = plugin.methods[method].Values.Single();
} else {
// get the hashcode for all the names of the types; use this as the key
var parameterHash = args.Select(arg => arg.GetType().Name.GetHashCode()).Aggregate(0, (res, next) => res | next);
methodToInvoke = plugin.methods[method][parameterHash];
}
return methodToInvoke.Invoke(objRef, args);
}
the result is an unhandled exception:
Exception has been thrown by the target of an invocation. StackTrace at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at FactSet.IS.Core.Infrastructure.PluginManager.IsolatedAssembly.Invoke(String activator, String method, Object[] args) at FactSet.IS.Core.Infrastructure.PluginManager.IsolatedAssembly.Invoke(String activator, String method, Object[] args) at FactSet.IS.Core.Infrastructure.PluginManager.PluginAppDomain.IsolatedAssemblyInvoke(String handler, String method, Object[] args) Inner Message Configuration system failed to initialize
I do not know what "Configuration system failed to initialize" means
Aucun commentaire:
Enregistrer un commentaire