Thanks for the suggestion, but I tried that and the device still won't
load the assembly. It only works with the setup I explained above. I
think the problem must be in the serialization of the assembly when
it's saved, and I was just wondering if anyone knew why having a
generic class with a constraint would make a difference to that.

I'm willing to fix it myself if someone could point me in the right
direction.

Thanks,
Henry

On Aug 17, 6:25 am, leblancmeneses <[email protected]> wrote:
> http://msdn.microsoft.com/en-us/library/d5x73970.aspx
>
> public class A<T> where T : class
>
> if you don't want to have a concrete B class.
>
> On Aug 16, 12:54 pm, kernelpanic99 <[email protected]> wrote:
>
>
>
> > Hi,
> > I'm writing an app that targets the Compact Framework on a particular
> > device, and Cecil has been working brilliantly for me so far, but I've
> > come across a weird problem to do with generics.
>
> > The problem occurs when there's a class with generic parameters in the
> > assembly I'm loading, for example:
>
> > public class A<T>
> > {
>
> > }
>
> > The assembly that Visual Studio creates loads fine on the device, but
> > if I use Cecil to load it and save it, making no modifications, the
> > device refuses to load it. Unfortunately I don't have an error message
> > from the device for this, but I assume it thinks the assembly is
> > invalid.
>
> > Luckily, I've found a sort of workaround. If there's a generic class
> > anywhere in the assembly that puts a constraint about the type of its
> > generic parameter, e.g.:
>
> > public class B
> > {
>
> > }
>
> > public class C<T> where T : B
> > {
>
> > }
>
> > Then I can run the assembly through Cecil and the device accepts it.
> > Without class C, the assembly only works if there are no generic types
> > at all, but with class C present, I can have as many generic types as
> > I want. Can you think of anything that might cause this behaviour? I'm
> > using Cecil 0.6 stable. Do you think it's worth trying this out on the
> > latest unstable build?
>
> > By the way, I've tested assemblies made from the same source code on
> > my PC and they work fine with or without class C, so it seems to be a
> > quirk in the Compact Framework implementation.
>
> > Thanks,
> > Henry
--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---

Reply via email to