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
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