Binding exception with dynamic keyword in c#

耗尽温柔 提交于 2019-12-11 09:27:58

问题


I am loading my assemblies at run time and I am also using Instance Activator to get the code at the runtime. Following code will summerize what I am doing:

dynamic powerTool;
System.Reflection.Assembly assembly = System.Reflection.Assembly.LoadFrom(
    @"C:\Users\c_desaik\Desktop\PowerTool.exe");
Type type = assembly.GetType("PowerTool.Automation");
powerTool = Activator.CreateInstance(type);    

Now, as you have noticed, Powertool has been declared as dynamic because I do not want my code to fail at Compile time and I want it to resolve all the operations at the Runtime.

While I do that the code fails to execute down the line with the following error:

An unexpected exception occurred while binding a dynamic operation

Now I thought that the entire concept behind the dynamic keyword was to be abl eto resove all the members and operation at the run time. How can I resolve this error?

来源:https://stackoverflow.com/questions/18392186/binding-exception-with-dynamic-keyword-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!