View Full Version : Spring.NET 0.6 on .NET Framework 2 Beta 1
patrickyong
06-24-2005, 03:53 AM
Can Spring.NET 0.6 build and run on .NET Framework 2 Beta 1? Hope those make it can share with me your experience
Rick Evans
06-27-2005, 04:03 PM
Hi Patrick
I recently (~4 weeks ago now) compiled the Spring.Core codebase against the 2.0 Framework.
There are some compilation issues... nothing that someone armed with a couple of hours, a pedantic mindset, and an #if 2_0 directive or two couldn't sort out though.
The compilation issues that I found were...
The System.Configuration assembly had to be referenced.
The ConfigurationSettings.GetConfig(string) method has been deprecated in favour of the ConfigurationManager.GetSection(string) method.
How soon do you intend using the 2.0 Framework? If there is enough call for this, one of the team will definitely address the issue.
Ciao
Rick
patrickyong
07-15-2005, 12:20 PM
I intend to apply Spring framework in Microsoft's Connected Systems Developer Competition.
I would be happy if someone can guide me to compiler Spring.net on .NET 2.0
patrickyong
07-15-2005, 03:05 PM
Inside Spring.Objects.Factory.Xml.XmlObjectDefinitionRead er
The below codes can't compiled in .NET 2
XmlValidatingReader vReader = new XmlValidatingReader(new XmlTextReader(stream));
Stream schemaStream = Assembly.GetExecutingAssembly().GetManifestResourc eStream(SchemaResourceKey);
vReader.Schemas.Add(XmlSchema.Read(schemaStream, new ValidationEventHandler(HandleValidation)));
vReader.ValidationType = ValidationType.Schema;
vReader.ValidationEventHandler += new ValidationEventHandler(HandleValidation);
reader = vReader;
AND
===
XmlTextReader xtr = null;
if (reader is XmlTextReader)
{
xtr = (XmlTextReader) reader;
}
else if (reader is XmlValidatingReader)
{
xtr = ((XmlValidatingReader)reader).Reader as XmlTextReader;
}
It returns a warning msg:
Warning 1 'System.Xml.XmlValidatingReader' is obsolete: 'Use XmlReader created by XmlReader.Create() method using appropriate XmlReaderSettings instead. http://go.microsoft.com/fwlink/?linkid=14202' D:\dotNet\spingnet\Spring.Net\src\Spring\Spring.Co re\Objects\Factory\Xml\XmlObjectDefinitionReader.c s 241 40 Spring.Core
How should I correct it?
Rick Evans
07-15-2005, 04:50 PM
Hi Patrick
Getting a 1.0 release out for the end of July is where all of the Spring.NET dev teams focus is right now. However, I did go through the codebase a while back (gee, a couple of months ago already), and I do have the changes necessary to build the codebase for the Spring.Core project against the .NET Framework 2.0.
In response to the first snippet of code in your post, this will sort you out; I'm pasting straight from the the two month old codebase that I previously 'prepped' for 2.0... just cut-and-paste ( :shock: ) the code in the NET_2_0 region and you will be sorted.
protected virtual XmlReader GetXmlReader(Stream stream, bool validating)
{
XmlReader reader = null;
if (validating)
{
#if NET_2_0
XmlReaderSettings settings = new XmlReaderSettings();
Stream schemaStream = Assembly.GetExecutingAssembly().GetManifestResourc eStream(SchemaResourceKey);
settings.Schemas.Add(XmlSchema.Read(schemaStream, new ValidationEventHandler(HandleValidation)));
settings.ValidationType = ValidationType.Schema;
settings.ValidationEventHandler += new ValidationEventHandler(HandleValidation);
reader = XmlReader.Create(stream, settings);
#else
XmlValidatingReader vReader = new XmlValidatingReader(new XmlTextReader(stream));
Stream schemaStream = Assembly.GetExecutingAssembly().GetManifestResourc eStream(SchemaResourceKey);
vReader.Schemas.Add(XmlSchema.Read(schemaStream, new ValidationEventHandler(HandleValidation)));
vReader.ValidationType = ValidationType.Schema;
vReader.ValidationEventHandler += new ValidationEventHandler(HandleValidation);
reader = vReader;
#endif
}
else
{
XmlTextReader treader = new XmlTextReader(stream);
reader = treader;
}
return reader;
}
In response to the second snippet from your post, well... darn, in the old codebase that I have I've just gone and deleted the offending section. I really should have commented it, 'cos I can't remember why I did it like this... the unit tests all pass when run against the .NET Framework 2.0, so I guess I must have been doing the right thing. Yes, hardly a confident ringing endorsement, but I was only investigating the 2.0 support in Spring.NET. Simply replace the offending second snippet with the following code (I must have been interrupted at this point, 'cos it hardly seems robust)...
XmlTextReader xtr = xtr = (XmlTextReader)reader;
There are some other issues... er, replace Assembly.LoadWithPartialName with Assembly.Load, use ConfigurationErrorsException instead of ConfigurationException, mmm... I think that was it. I will personally attend to making the Spring.NET codebase fully .NET Framework 2.0 compliant and buildable (is that a word?) as soon as the 1.0 release is out the door. I've gone and raised a JIRA issue (http://opensource.atlassian.com/projects/spring/browse/SPRNET-131) for this so that it doesn't slip under the cracks (can't believe there wasn't already an issue for this).
If you find any other 2.0 warnings or errors other than the one's I have mentioned here, could you please add a comment to the JIRA issue in addition to posting on this thread? Cheers, and good luck with the competition... what are you working on anyway, or is it confidential :) ?
Ciao
Rick
vBulletin® v3.7.3, Copyright ©2000-2009, Jelsoft Enterprises Ltd.