Hi Krzysztof
I am facing the same issue, but this time if you remove the constructor 
with no parameters, but add only a single constructor with or multiple 
constructors with parameters, then the proxy creation fails. How can I 
create proxies for something like that, can DP look into the target object 
and invoke proper constructor? or somehow clone the target class rather 
than creating another instance? Hope I am asking proper questions.

            HelloWorld target = new HelloWorld("something");
            target.Name = "Hello";

            target = proxy.CreateClassProxyWithTarget<HelloWorld>(target, 
new HelloInterceptor());

     I get following error
.
Can not instantiate proxy of class: ConsoleApplication1.HelloWorld.
Could not find a parameterless constructor.

Rusty

On Friday, April 8, 2011 8:52:22 PM UTC-5, Krzysztof Koźmic wrote:
>
> Andrés,
>
> That's a bug. DP is confused about the two proxy types you create (with 
> and without target)  and it wants to reuse the first one in the second 
> case which fails. This is fixed now.
>
> As a workaround if you need to create both, standard class proxies and 
> class proxies with target use two separate proxyGenerators for that.
>
> This is fixed now in the trunk: 
> http://issues.castleproject.org/issue/DYNPROXY-158
>
> Thanks for reporting this.
> cheers,
> Krzysztof
>
> On 09/04/2011 5:52 AM, [email protected] <javascript:> wrote:
> > Hi,
> >
> > I'm trying to learn how to use the dynamic proxy, and when making a 
> > simple example code I ran into a problem when using the method 
> > "CreateClassProxyWithTarget".  I'm trying to wrap an existing instance 
> > into a proxy and I get the following exception: "Could not find a 
> > parameterless constructor". Thing is the target type does have a 
> > parameterless public constructor.
> >
> > Code attached.
> >
> > Thanks for any help you can give me.
> >
> > -- 
> > Andrés Blanco Morales
> > -- 
> > 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] <javascript:>.
> > To unsubscribe from this group, send email to 
> > [email protected] <javascript:>.
> > For more options, visit this group at 
> > http://groups.google.com/group/castle-project-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/castle-project-users/-/j-q1oiOkhGQJ.
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