PDA

View Full Version : ProxyTargetType to true with Windows Form... Bug?


m_peretz
01-23-2008, 11:29 AM
I am not sure if this is a bug or not, but I am unable to use ProxyTargetType = true on a Form class. I get an error with the proxy at configuration time. I tried on an empty winform and it crashed, but when I use my factory on a regualr class it works... here is a the code

Note: Form1 = a regualr .net winform with nothing in it, Expect .net generated code when creating it.



<object id="foo" type="MvpExample.Form1, MvpExample" singleton="false"/>

<object id="LogonViewProxy"
type="Spring.Aop.Framework.ProxyFactoryObject, Spring.Aop">
<property name="ProxyTargetType">
<value>true</value>
</property>
<property name="TargetSource">
<object type="Spring.Aop.Target.PrototypeTargetSource, Spring.Aop">
<property name="TargetObjectName" value="foo" />
</object>
</property>
</object>

I am using Spring 1.1, the error I get is this:

Error creating context 'spring.root': The property with name ArraySubType can't be found in the type System.Runtime.InteropServices.MarshalAsAttribute, but is present as a named property on the attributeData [System.Runtime.InteropServices.MarshalAsAttribute( (System.Runtime.InteropServices.UnmanagedType)44, ArraySubType = 0, SizeParamIndex = 0, SizeConst = 0, IidParameterIndex = 0, SafeArraySubType = 0, MarshalType = "System.Windows.Forms.Control+ActiveXFontMarshaler", MarshalTypeRef = System.Windows.Forms.Control+ActiveXFontMarshaler, MarshalCookie = "")]

Please let me know if this is a bug, or if I am using the feature wrong. I am trying to create an Aspect on a Form using inheritance, for the simple reason that I need to have Application.Run work with it.

Mark Pollack
01-23-2008, 06:24 PM
Hi,

I can confirm this is a bug/limitation in the current proxy code. I've open a JIRA issue to investigate.

By way of a workaround, what I've done for WinForm apps is introduce an 'IView' interface.

Cheers,
Mark

m_peretz
01-23-2008, 06:35 PM
Hi,

I can confirm this is a bug/limitation in the current proxy code. I've open a JIRA issue to investigate.

By way of a workaround, what I've done for WinForm apps is introduce an 'IView' interface.

Cheers,
Mark

Hi Mark,

Thank you for taking the time to look into it. However I don't understand the workaround? How can I show a windows form with an aspect around it, as I need the actual Form object with Application.Run, I have tried to use ITargetAware introduction to my form, but it gave me the proxy and not the source object (which is not of type Form)...

Maybe you can direct me to a sample or snippet of code showing the wrok-around.

Mark Pollack
01-23-2008, 07:13 PM
Hi,

Sorry, you are right, what I said doesn't make any sense. Let us look into it and get back to you, this is an important use-case.

Cheers,
Mark

m_peretz
01-24-2008, 02:59 AM
Hi,

Sorry, you are right, what I said doesn't make any sense. Let us look into it and get back to you, this is an important use-case.

Cheers,
Mark

Hi Mark,

Thanks for looking into it, I will check this thread for updates.

Mark Pollack
01-24-2008, 04:15 AM
Hi,

I committed a fix for the bug (http://jira.springframework.org/browse/SPRNET-852) you found, though there is yet another one lurking. Hopefully I'll have more info for you tomorrow.

Cheers,
Mark

m_peretz
01-29-2008, 10:42 AM
Hi,

Is there a way for me to get hold of this fix?

Mark Pollack
01-29-2008, 02:57 PM
Hi,

Unfortunately no since Sourceforge CVS has been broken for over a week. The build server can't check out the code. I've been in a stupid support email exchange with Sourceforge, the conclusion of which is that I'll switch to a SpringSource hosted Subversion repository this week.

In anycase, the bad news is that the fix above isn't enough for you to do what you want. Long story short, after looking into the issue more with Bruno we need to improve how we do inheritance based proxies. We have the basic mechanism for the proxy working but it needs to be integrated into the AOP/DI infrastructure. The amount of work is more than we can do for a 1.1.1 release since some APIs and contracts will change, but I hope that we can get something in the next few weeks are part of the initial work for 1.2. I'll remember to post back here once we have something for you to use. Apologies.

Cheers,
Mark

m_peretz
02-26-2008, 11:49 AM
Hi,

Are there any news on this issue?

Mark Pollack
02-27-2008, 12:51 AM
Hi,
There has been some development, Bruno has committed the basics of using inheritance to create the aop wrapper, but the approach is more type centric than before, requiring a other changes in configuration (less so in the API) which have not been sorted out. I'll ping Bruno to comment further.
Cheers,
Mark

m_peretz
05-20-2008, 12:14 AM
Any news on this issue, let me know if you can provide a timeline?

Bruno Baia
05-28-2008, 10:53 AM
Hi,

I've made a protoype some time ago, I've uploaded the sample code here :
http://opensource.atlassian.com/confluence/spring/download/attachments/708/WindowsFormsAndAop.zip
(Update binaries to 1.1.2)


- Bruno

Mark Pollack
09-15-2008, 08:03 PM
Hi,

The 1.2 M1 release contains the functionality for this use-case. Some docs are here (http://www.springframework.net/doc-latest/reference/html/aop.html#aop-inheritancebasedaopconfigurer).

Cheers,
Mark