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 -~----------~----~----~----~------~----~------~--~---
