Re: Import Type by name of possibly TypeForwarded type.

39 views
Skip to first unread message

Simon

unread,
May 9, 2013, 8:56:36 PM5/9/13
to mono-...@googlegroups.com
you have to handle it explicitly. 

for example


        var actionDefinition = msCoreTypes.FirstOrDefault(x => x.Name == "Action");
        if (actionDefinition == null)
        {
            actionDefinition = systemTypes.FirstOrDefault(x => x.Name == "Action");
        }

On Friday, 10 May 2013 00:23:08 UTC+10, Damian Reeves wrote:
I'm new to Mono.Cecil and I'm trying to do some AOP with it to create a Fody Addin.

I'd like to add a property of type System.Windows.Input.ICommand to a class using Mono.Cecil.

Prior to .NET 4.5 this type existed in PresentationCore, but if .NET 4.5 is installed this type exists in System.dll, thanks to the magic of TypeForwarding.

How can I properly import the type so that it works properly on machines with and without .NET 4.5 (i.e. I need this to work properly whether or not the type has been forwarded) even if the assembly was created on a machine with .NET 4.5?


Damian Reeves

unread,
May 10, 2013, 9:25:37 AM5/10/13
to mono-...@googlegroups.com
Thanks. This works perfectly!

Simon Cropp

unread,
May 10, 2013, 9:31:08 AM5/10/13
to mono-...@googlegroups.com
do u want me to also answer the SO question?

On Fri, May 10, 2013 at 11:25 PM, Damian Reeves <dam...@gmail.com> wrote:
> Thanks. This works perfectly!
>
> --
> --
> --
> mono-cecil
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "mono-cecil" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/mono-cecil/_x24k0SOBn0/unsubscribe?hl=en.
> To unsubscribe from this group and all its topics, send an email to
> mono-cecil+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Damian Reeves

unread,
May 10, 2013, 9:33:23 AM5/10/13
to mono-...@googlegroups.com
Yeah sure. I didn't want to answer it myself.
Reply all
Reply to author
Forward
0 new messages