Hey,
On 1/22/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hi,
> I would like to ask how can I call (run) a function of an assembly
> with Cecil?
Am sorry but I don't think you've understood what Cecil does :)
Cecil is an assembly that will create for you a graph of objects of
what an assembly contains, but it has no relation whatsoever with the
runtime.
So you cannot execute code from a Cecil assembly. You can read an
assembly, modify it, or create one from scratch, then load it in the
runtime for execution. And that's pretty much it.
> For example, I have an assembly. In <Module>-Namespace of this
> assembly there is a function with 2 args as Caculate(int arg1, int
> arg2). This function is private. And I would like to call this one
> from another assembly (seperate file) and receive the result of this
> function.
>
> With the namespace System.Reflection of Microsoft we can do like that
>
> *********
> Assembly a = Assembly.LoadWithPartialName("MyAssembly");
> object obj = a.CreateInstance("MyType");
> Type[] signature = new Type[] {typeof(int), typeof(string)};
> MethodInfo method = obj.GetType().GetMethod("MyMethod",
> signature);
> object[] parameters = new object[] { 123, "abc" };
> method.Invoke(obj, parameters);
> **********
>
> I don't know how can I do it with Cecil?
> Thank you.
> >
>
--
Jb Evain <[EMAIL PROTECTED]>
--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---