diff --git a/src/Spring/Spring.Core/Proxy/CompositionProxyTypeBuilder.cs b/src/Spring/Spring.Core/Proxy/CompositionProxyTypeBuilder.cs index 8e9ad773..26717afd 100644 --- a/src/Spring/Spring.Core/Proxy/CompositionProxyTypeBuilder.cs +++ b/src/Spring/Spring.Core/Proxy/CompositionProxyTypeBuilder.cs @@ -197,8 +197,8 @@ namespace Spring.Proxy { il.Emit(OpCodes.Ldarg_S, i); } - il.Emit(OpCodes.Newobj, TargetType.GetConstructor( - ReflectionUtils.GetParameterTypes(constructor.GetParameters()))); + + il.Emit(OpCodes.Newobj, constructor); il.Emit(OpCodes.Stfld, targetInstance); } diff --git a/test/Spring/Spring.Core.Tests/Context/Support/ContextRegistryTests.cs b/test/Spring/Spring.Core.Tests/Context/Support/ContextRegistryTests.cs index 27b3437c..af94a10b 100644 --- a/test/Spring/Spring.Core.Tests/Context/Support/ContextRegistryTests.cs +++ b/test/Spring/Spring.Core.Tests/Context/Support/ContextRegistryTests.cs @@ -169,6 +169,14 @@ namespace Spring.Context.Support IApplicationContext context = ContextRegistry.GetContext("bingo"); } + [Test] + public void CanBuildProxyForClassWithProtectedConstructor() + { + CompositionProxyTypeBuilder typeBuilder = new CompositionProxyTypeBuilder(); + typeBuilder.TargetType = typeof(ClassWithProtectedCtor); + typeBuilder.BuildProxyType(); + } + [Test] public void ClearWithDynamicProxies() { diff --git a/test/Spring/Spring.Core.Tests/Objects/ClassWithProtectedCtor.cs b/test/Spring/Spring.Core.Tests/Objects/ClassWithProtectedCtor.cs new file mode 100644 index 00000000..82005da0 --- /dev/null +++ b/test/Spring/Spring.Core.Tests/Objects/ClassWithProtectedCtor.cs @@ -0,0 +1,13 @@ +namespace Spring.Objects +{ + public class ClassWithProtectedCtor : IOther + { + protected ClassWithProtectedCtor() + { + } + + public void Absquatulate() + { + } + } +} \ No newline at end of file diff --git a/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2010.csproj b/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2010.csproj index 04a141ef..6deafcd0 100644 --- a/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2010.csproj +++ b/test/Spring/Spring.Core.Tests/Spring.Core.Tests.2010.csproj @@ -339,6 +339,7 @@ Code +