I ended up finding a hacky workaround (gather type references from the 
assembly). This project is just a quick prototype so it doesn't matter. 

For that solution though, are you sure that would work? I believe I did 
that sorta and ended up getting (swallowed) exceptions at runtime for "The 
file System.Text.Encoding.dll could not be found" presumably due to the 
WinRT sandbox. I noticed also the issue in your issue tracker about better 
WinRT support in general. I assume all of this will get a lot easier when 
that gets worked on?

On Thursday, September 20, 2012 12:54:57 PM UTC-4, Jb Evain wrote:
>
> Hi, 
>
> It's quite simple, you have to use the Cecil type system instead of 
> System.Reflection which is bound to the executing version. 
>
> Open the assembly containing Encoding.UTF8 you need with Cecil, and 
> import its reference in your module. 
>
> Best, 
>
> Jb 
>
> On Thu, Sep 20, 2012 at 6:19 PM, earlz 
> <[email protected]<javascript:>> 
> wrote: 
> > Hi there, I've been trying to create a small project that basically will 
> > intercept a call to a certain method in a WinRT application and replace 
> the 
> > call with a generated static method. 
> > 
> > Everything has been working great until now. I inject the code with a 
> > regular desktop application. The problem is that I use 
> > 
> > il.Emit(OpCodes.Call, 
> > Module.Import(typeof(System.Text.Encoding).GetMethod("get_UTF8"))); 
> > 
> > This generates the il 
> > 
> > call class [mscorlib]System.Text.Encoding 
> > [mscorlib]System.Text.Encoding::get_UTF8() 
> > 
> > But, I appear to need it to generate 
> > 
> > call class [System.Text.Encoding]System.Text.Encoding 
> > [System.Text.Encoding]System.Text.Encoding::get_UTF8() 
> > 
> > 
> > 
> > How do I go about adding a type reference to a built in assembly that 
> isn't 
> > in my injecting application? 
> > 
> > 
> > 
> > 
> > -- 
> > -- 
> > mono-cecil 
>

-- 
--
mono-cecil

Reply via email to