Interestingly - for completely different reasons:
Unhandled Exception: System.TypeInitializationException: The type
initializer for 'ConsoleApplication9.Program' threw an exception. --->
System.TypeInitializationException: The type initializer for
'Castle.DynamicProxy.Generators.Emitters.StrongNameUtil' threw an
exception. ---> System.NotSupportedException: The Deny stack modifier
has been obsoleted by the .NET Framework. Please see
http://go.microsoft.com/fwlink/?LinkId=155571 for more information.
at System.Security.CodeAccessSecurityEngine.Check(Object demand,
StackCrawlMark& stackMark, Boolean isPermSet)
at
System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap,
StackCrawlMark& stackMark)
at System.Security.CodeAccessPermission.Demand()
at Castle.DynamicProxy.Generators.Emitters.StrongNameUtil..cctor()
in
c:\TeamCity\buildAgent\work\f0c43d96621436a8\src\Castle.Core\DynamicProxy\Generators\Emitters\StrongNameUtil.cs:line
40
--- End of inner exception stack trace ---
at
Castle.DynamicProxy.Generators.Emitters.StrongNameUtil.get_CanStrongNameAssembly()
at ConsoleApplication9.Program.tuneDynamicProxy() in
c:\users\xtoff\documents\visual studio
2010\Projects\ConsoleApplication9\ConsoleApplication9\Program.cs:line 58
at ConsoleApplication9.Program..cctor() in
c:\users\xtoff\documents\visual studio
2010\Projects\ConsoleApplication9\ConsoleApplication9\Program.cs:line 52
--- End of inner exception stack trace ---
at ConsoleApplication9.Program.Main(String[] args)
Notice it fails even before any attempt to generate the proxy.
Anyway - I remember there was some bug in VS2008 debugger, so you may
have hit just that.
Which version of DP are you running?
I don't think there's anything I can do. I was able to reproduce the
issue, and it looks like the debugger in .NET 3.5 gets confused about
which generic parameters belong to which method.
DP generates perfect code, and it if you run PeVerfiy (I did) it finds
no issue.
Your best option is to upgrade to .NET 4 where this bug does not exist.
cheers,
Krzysztof