Hi, I think you might have run into this .NET CLR bug: http://connect.microsoft.com/VisualStudio/feedback/details/311821/attached-debugger-causes-typeloadexception-or-verificationexception-in-dynamic-code-generation-scenario#details (supposedly the same bug: http://connect.microsoft.com/VisualStudio/feedback/details/270717/reflection-emit-chokes-on-method-type-parameters#details).
What .NET version are you running on? Cheers, Fabian On Fri, Jul 13, 2012 at 11:05 AM, srudin <[email protected]> wrote: > According to Daniel Cazzulino, the owner of the Moq project that internally > uses Castle, I have what I consider to be a bug in the Castle framework > (first post see here: > https://groups.google.com/forum/?fromgroups#!topic/moqdisc/ad3xwXQ585I ). I > have striped it down to a very simple setup and I hope you are able to > reproduce this and find a solution. Steps to reproduce: > > 1. Make a new solution / class library project. > 2. Add references to Moq and NUnit. > 3. SIGN the project (with any new key). > 4. Replace the Class1 content with the following: > > using System; > using Moq; > using NUnit.Framework; > > namespace Whatever > { > [TestFixture] > public class ItsMagic > { > public abstract class BaseService<T> where T : class > { > public virtual void FindAll() > {} > > public virtual void FindAllLightWeights<TParameter>() where TParameter : > class > {} > > public virtual void FindAllAsDictionary<PROBLEMPARAMETER>() where > PROBLEMPARAMETER : IDisposable > {} > } > > [Test] > public void Test() > { > Mock<BaseService<ItsMagic>> service = new Mock<BaseService<ItsMagic>>(); > service.Object.FindAllLightWeights<ItsMagic>(); > } > } > } > > Now RUNNING the test succeeds but DEBUGGING the test throws the following > exception: > > System.TypeLoadException : GenericArguments[0], "Whatever.ItsMagic" in > "Castle.Proxies.Invocations.BaseService`1_FindAllLightWeights[PROBLEMPARAMETER]" > verletzt die Einschränkung des "PROBLEMPARAMETER"-Typparameters. > bei Castle.Proxies.BaseService`1Proxy.FindAllLightWeights<TParameter>() > bei Whatever.ItsMagic.Test() in Class1.cs: line 28.System.TypeLoadException > : GenericArguments[0], "Whatever.ItsMagic" in > "Castle.Proxies.Invocations.BaseService`1_FindAllLightWeights[PROBLEMPARAMETER]" > verletzt die Einschränkung des "PROBLEMPARAMETER"-Typparameters. > bei Castle.Proxies.BaseService`1Proxy.FindAllLightWeights<TParameter>() > bei Whatever.ItsMagic.Test() in Class1.cs: line 28. > > It can be fixed by either one of the following changes: > a) not signing the assembly > b) restricting PROBLEMPARAMETER to be of "class" instead of "IDisposable" > c) reordering the methods so that FindAllAsDictionary() is the first or > second method of BaseService > d) removing any of the methods > > Especially c) gives me the impression that this is a bug. Can you reproduce > it? And can you fix it? > > Thx & kind regards > Sandro > > -- > You received this message because you are subscribed to the Google Groups > "Castle Project Development List" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/castle-project-devel/-/VCBSrmhuaRQJ. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/castle-project-devel?hl=en. -- You received this message because you are subscribed to the Google Groups "Castle Project Development List" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/castle-project-devel?hl=en.
