PDA

View Full Version : Transparent proxys


Tolo
10-01-2005, 07:07 PM
Hi,

I have discovered a little problem with the 1.0 release. I was using the RC1 and my application was working fine, but when I upgraded to Spring.Net 1.0 I started to have several strange errors from Spring.Net.

Several of my objects look like:


<object id="DatosGenerales" type="Engel.Business.Comun.DatosGenerales, Engel.Business.Comun">
<constructor-arg name="gestorConfiguracion">
<ref object="GestorConfiguracion"/>
</constructor-arg>
<property name="GestorMonedas">
<ref object="GestorMonedas"/>
</property>
<property name="GestorPaises">
<ref object="GestorPaises"/>
</property>
<property name="BeneficioMinimo" value="15"/>
</object>

GestorMonedas, GestorPaises and GestorConfiguracion are a remote objects accessed via a transparent Proxy.

When I try to get an instance of DatosGenerales I get an exception like

Spring.Objects.Factory.ObjectCreationException: Error creating object with name ' DatosGenerales ' defined in 'assembly [Engel.Business.Comun, Version=1.0.2100.21875, Culture=neutral, PublicKeyToken=null], resource [Engel.Business.Comun.Engel.Business.Comun-VARIOS.xml] line 4' : Initialization of object failed : Method not found: (null). ---> System.MissingMethodException: Method not found: (null).

I have been checking the Spring.Net code and I believe that I have found the problem in (some comments inline)

SetNonIndexedProperty(string propertyName, string actualName, object val) in ObjectWrapper.cs
<----- val is a transparent proxy, so is any interface
if ( ( (val is IList) || (val is IDictionary) || (val is ISet) ) &&
(!pi.PropertyType.IsAssignableFrom(newValue.GetTyp e())) )
{
if (!AddToCollections(val, actualName, propertyName))
{
//Try anyway...
SetPropertyValue(pi, newValue);
}
}
else
{
SetPropertyValue(pi, newValue);
}
…….

private bool AddToCollections(object val, string actualName, string propertyName)
{
bool added = false;
// try adding values if property is a list...
if (val is IList) <---- val is a transparent proxy so is true
{
IList propValue = (IList) GetPropertyValue(actualName);
foreach (object el in (IList) val) <-----BUUM,val is not a IList
{
propValue.Add(el);
}
added = true;
}


The code checks if val is IList or if val is IDictionary …. I believe that’s the problem because val is a transparent proxy so val is any interface. When Spring.Net tries to use val as IList an exception is raised.

I did not check the latest (CVS) code, so I don’t know if this problem is fixed yet.


Cheers,
Tolo

Rick Evans
10-01-2005, 07:45 PM
Hi Tolo

Man, you are having a field day on the bug front. Thanks for taking the time to report these issues, it's much appreciated.

Yeah, that looks like an issue we had addressed some months back... evidently something slipped under the testing radar. Darn.

I have gone and created a JIRA issue (http://opensource2.atlassian.com/projects/spring/browse/SPRNET-200) for the bug you have found. I've not got the time to investigate it (or address it right now), but it will definitely be fixed before the 1.0.1 release in November.

Ciao
Rick

Tolo
10-01-2005, 07:55 PM
Hi Tolo

Man, you are having a field day on the bug front. Thanks for taking the time to report these issues, it's much appreciated.

Thanks to you for your marvelous work with Spring.Net :D


Yeah, that looks like an issue we had addressed some months back... evidently something slipped under the testing radar. Darn.

I have gone and created a JIRA issue (http://opensource2.atlassian.com/projects/spring/browse/SPRNET-200) for the bug you have found. I've not got the time to investigate it (or address it right now), but it will definitely be fixed before the 1.0.1 release in November.


Cool, I will use the RC1 version till the 1.0.1 release.

Thanks again.

Mark Pollack
10-05-2005, 03:56 PM
Hi,

My bad - at least I was the one that mucked with that code in order to support configuration of custom collection classes. I'll investigate and get back to you. Thanks for reporting it.

Cheers,
Mark