There is thing you know you should do, but with too much confidence, you will forget. This was the case this morning with the Activator.CreateInstance method.
I was getting this error :
Exception has been thrown by the target of an invocation.
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOn
ly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& b
NeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCach
e)
at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisi
bilityChecks, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder bin
der, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binde
r binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(String assemblyName, String typeName, Bool
ean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureI
nfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMar
k& stackMark)
at System.Activator.CreateInstance(String assemblyName, String typeName)
at DynamicsGP.GPListener.Program.Main(String[] args)
After double and triple checking with Reflector and outputing everything possible to the console, I wasn’t able to figure out what I did wrong.
The solution was easy, I was not checking the InnerException of the exception. Turn out is was only a missing dll.