XML configuration problem

Sep 6, 2007 at 3:45 PM
Hi!

I'm fed up with trying to setup the validation and now I'm almost to give up.

First of all, I turn all CLR Exceptions handling, run Debug and notice that I got:

In Global.asax.cs there is an initialization:

ConfigurationService.AddAssembly(typeof(Service).Assembly);

Service ( : System.Web.Services.WebService) is a name of class that is WebService handler.
This is the last line written by my that executes.


FileNotFoundException Could not load file or assembly 'ValidationFramework.XmlSerializers, Version=1.10.0.0, Culture=neutral, PublicKeyToken=2f07bd240683f08a' or one of its dependencies. The system cannot find the file specified.":"ValidationFramework.XmlSerializers, Version=1.10.0.0, Culture=neutral, PublicKeyToken=2f07bd240683f08a
at ConfigurationServices.cs line 227

It looks in is inner-handled, and I assume it is no problem, my code runs further.

Than, I can see that in line 101 of TypeDescriptor.cs the result of assignment is null.
It causes further Exception (NullReferenceException) in PropertyDescriptor.cs line 41.

I have no idea what's wrong with this.

Validated class definition is very simple for now, it looks like this:

namespace epl
{
public class QueryCheckService : ValidatableBase
{
public string BrokerRefNo;
public string Broker;
public string Agent;
public QueryCheckService()
: base(false)
{
}
}
}

XML Configuration as follows:


<?xml version="1.0" encoding="utf-8" ?>
<validationMapping xmlns="urn:validationFramework-validationDefinition-1.5">
<class typeName="epl.QueryCheckService, WebApplication1">
<property name="Broker">
<rule typeName="RequiredStringRuleConfigReader" initialValue="aaa"/>
</property>
</class>
</validationMapping>


I hope we can handle this..., ufff.
Regards, Mike
Sep 6, 2007 at 11:07 PM
Mike

Is that your exact class definition? I.e. you haven’t used shorthand to write it? If so you need to make your fields properties. The current iteration of the framework does not support fields. I will be looking into this in a future version.
So you class should look like this.
    public class QueryCheckService : ValidatableBase
    {
        private string brokerRefNo;
        private string broker;
        private string agent;
        public QueryCheckService()
            : base(false)
        {
        }
 
 
        public string Agent
        {
            get
            {
                return agent;
            }
            set
            {
                agent = value;
            }
        }
        public string Broker
        {
            get
            {
                return broker;
            }
            set
            {
                broker = value;
            }
        }
        public string BrokerRefNo
        {
            get
            {
                return brokerRefNo;
            }
            set
            {
                brokerRefNo = value;
            }
        }
    }
The exception you noticed with “'ValidationFramework.XmlSerializers” is most likely caused by the .net framework creating a serialization assembly. Serialization assemblies are created at runtime on first serialization of any type in an assembly. They provide more efficient code, than your standard class code, for serialization. I imagine the process for creating one goes something like this
-try and load serialization assembly
-if failed create one.

Your exception is happening in the try phase. I will do a little more research on this and get back to you. I may even ship a pre generated serialization assembly to speed things up a little. BTW if you want to pre gen your own your can use the sgen tool (http://msdn2.microsoft.com/en-us/library/bk3w6240(VS.80).aspx)

Regards
Simon

Sep 7, 2007 at 1:25 PM
Simon

Thanks a lot for help. In my case I have no problem with class generated with get/set methods. Problem come when I tried to do what I described, so probably it is the right answer. I'll try fix it right now. Thanks

Mike