Hey Greg, I'm not 100% sure I understand your description of the issue, but you can't use a type defined in a newer version of the .NET framework in an assembly targeting an older version.
Is this what you're trying to do? If so, you'll need to change the target framework for the assembly, and fix up its references to the newer version, but it can get hairy if you're using 3rd party assemblies. Jb On Sun, Jul 26, 2015 at 6:20 PM, Greg Rosenbaum <[email protected]> wrote: > Hey there. I've sort of run into a problem, and I'm wondering if anyone can > help me. > > I'm trying to modify an assembly that uses framework version 3.5, but I > don't want to be limited to that framework myself. I want to embed some > attributes into it, and to do that I need to get references to their types, > from the correct assembly version. The attributes are standard .NET > attributes and their assemblies live in the GAC. > > I can't seem to manage to do that. I can't import my own types, because > they're from a higher version assembly, and I trying to get the correct > assembly by name (using Module.AssemblyResolver.Resolve), doesn't seem to > work, even if I specify the exact version I want. It just resolves the wrong > assembly. > > The only thing that seemed to work was using > System.Reflection.Assembly.ReflectionOnlyLoad to load the assembly from its > AssemblyName (version + name), and using that FullName (which includes the > public key) to resolve the assembly using AssemblyResolver. However, this > doesn't work properly either, because then the modified assembly gets an > indirect dependency on a higher version of mscorlib, somehow. Also, this > seems like a really roundabout way to do this. > > -- > -- > -- > mono-cecil > --- > You received this message because you are subscribed to the Google Groups > "mono-cecil" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. -- -- -- mono-cecil --- You received this message because you are subscribed to the Google Groups "mono-cecil" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
