Following code causes exception if executed under VS2008 debugger.

Exception:
System.TypeLoadException: GenericArguments[0], 'ST2', on
'Castle.Proxies.Invocations.IService_Method2[ST1]' violates the
onstraint of type parameter 'ST1'.
   at Castle.Proxies.IServiceProxy.Method2[ST2](ST2 t)
   at DPGenericsUnderDebugIssueDemo.Program.Main(String[] args) in C:
\WORK\TestsAndTries\DPGenericsUnderDebugIssueDemo
\DPGenericsUnderDebugIssueDemo\Program.cs: line 61


This:
"GenericArguments[0], 'ST2', on
'Castle.Proxies.Invocations.IService_Method2[ST1]'"
looks very strange....


If executed without debugger it work ok.


    public class C : ICloneable
    {
        public object Clone()
        {
            throw new NotImplementedException();
        }
    }


    public interface IService
    {
        void Method1<ST1>(ST1 t) where ST1 : class, new();
        void Method2<ST2>(ST2 t) where ST2 : ICloneable;
    }

    public class Component : IService
    {
        public void Method1<CT1>(CT1 t) where CT1 : class, new()
        {
            Console.WriteLine(string.Format("Method1 CT1:{0}", typeof
(CT1)));
        }

        public void Method2<CT2>(CT2 t) where CT2 : ICloneable
        {
            Console.WriteLine(string.Format("Method2 CT2:{0}", typeof
(CT2)));
        }
    }

    internal class Program
    {
        [SecurityPermission(SecurityAction.Deny, Unrestricted = true,
Flags = SecurityPermissionFlag.UnmanagedCode)]
        private static void tuneDynamicProxy()
        {
            Console.WriteLine(StrongNameUtil.CanStrongNameAssembly);
        }


        static Program()
        {
            //Restrict signed assembly generation
            tuneDynamicProxy();
        }

        private static void Main(string[] args)
        {
            ProxyGenerator g = new ProxyGenerator();
            var proxy = g.CreateInterfaceProxyWithTarget<IService>(new
Component(), new IInterceptor[0]);


            try
            {
                proxy.Method1(new C());
                proxy.Method2(new C());
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            finally
            {
                Console.ReadLine();
            }
        }
    }

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" 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-users?hl=en.

Reply via email to