设置参数调用方法
我有一个关于.Net CF 3.5 Reflection的问题。我正在调用这样的预期方法,
object n= instance.Type.GetMethod("DoSome"
).Invoke(instance.Instance,
new object[] { commandKeys }
);
commandKey是我的参数列表,instance.Type和instance.Instance不为空。 方法正常调用,但是当我在“DoSome”方法中设置任何属性(属于我调用的类)时,属性没有值(默认值)。
public class CSet:ITask
{
public void DoSome
{
SomeProperty=true;
OnTaskCompleted(this);
}
}
我正在捕获包含“ITask”接口的“OnTaskCompleted”委托,但就像我说的,ITask SomeProperty 没有我给定的值,
谢谢您的回答。
I have a question about .Net CF 3.5 Reflection.I am invoking expected something method like this,
object n= instance.Type.GetMethod("DoSome"
).Invoke(instance.Instance,
new object[] { commandKeys }
);
commandKey is my parameter list, instance.Type and instance.Instance is not null.
Methods invokes normally but, when I set any property(belongs to which I am calling class) in "DoSome" method, property dont have a value(default value).
public class CSet:ITask
{
public void DoSome
{
SomeProperty=true;
OnTaskCompleted(this);
}
}
I am catching "OnTaskCompleted" delegate which contains "ITask" interface but like i said ITask SomeProperty has not my given value
Thx your answers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您说“方法正常调用”,但同时您声称方法内的代码未执行。您如何知道该方法已被调用?
您确定
instance.Instace
与您检查SomeProperty
并捕获OnTaskCompleted
的实例相同吗?You say that the "Methods invokes normally", but at the same time you claim that the code inside the method is not executed. How do you know that the method is invoked at all?
Are you sure that
instance.Instace
is the same instance you checkSomeProperty
on, and catchOnTaskCompleted
from?