File-based XML mapping loading problem

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
crazypit
Posts: 163
Joined: Wed 15 Apr 2009 08:43

File-based XML mapping loading problem

Post by crazypit » Mon 27 Dec 2010 12:23

Hello,

When i try to load a file-based XML mapping through the code:

Code: Select all

 Stream contextStream = File.OpenRead("ExrayDataContext.lqml");
            ServerSessionRegistry.MappingSource =
              Devart.Data.Linq.Mapping.XmlMappingSource.FromStream(contextStream);
            contextStream.Close();
I get an XmlSchemaValidation exception with the message "Documentation" and the following stack trace:

at Devart.Data.Linq.Mapping.aj.a(ad A_0, XmlReader A_1)
at Devart.Data.Linq.Mapping.aj.b(ad A_0, XmlReader A_1)
at Devart.Data.Linq.Mapping.aj.c(XmlReader A_0)
at Devart.Data.Linq.Mapping.aj.g(XmlReader A_0)
at Devart.Data.Linq.Mapping.XmlMappingSource.FromReader(XmlReader reader)
at Devart.Data.Linq.Mapping.XmlMappingSource.FromStream(Stream stream)

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Mon 27 Dec 2010 13:57

Thank you for your report. We are already working on this problem, but cannot provide any timeframe at the moment.

A possible workaround is to remove all non-standard keywords (e.g., 'Documentation', 'Precision', 'MaxLength') from the .lqml file.

crazypit
Posts: 163
Joined: Wed 15 Apr 2009 08:43

Post by crazypit » Tue 28 Dec 2010 15:08

Hello,

I removed all Documentation entries from the XML file and the loading seems to work. Nevertheless, i get an exception during the first constructor call :

ArgumentException: An item with the same key has already been added.

at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at Devart.Data.Linq.Mapping.aw.a(DataProvider A_0)
at Devart.Data.Linq.DataContext.a(Object A_0, MappingSource A_1, Type A_2)
at Devart.Data.Linq.DataContext..ctor(String connectionString, MappingSource mapping)

What is the kind of this key? I searched my lqml file and did not find any duplicates and the mapping validates ok.

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Wed 05 Jan 2011 10:16

Sorry for the delay. I will send you a sample in a letter, please check that it was not blocked by your mail filter. Please specify what should be changed in the test project, or send us your model with which the issue can be reproduced.

crazypit
Posts: 163
Joined: Wed 15 Apr 2009 08:43

Post by crazypit » Fri 07 Jan 2011 08:32

It seems that the problem is in the way i use the Datacontext class because the first time the constructor is called, everything works ok and the problem arises on the second call.

Let me explain:

At the start of the program, i load the XML mapping file, create a MappingSource object and keep it in an application wide static property of a static class for future use (ServerSessionRegistry.MappingSource):

Code: Select all

Stream contextStream = File.OpenRead("ExrayDataContext.lqml");
            ServerSessionRegistry.MappingSource =
              Devart.Data.Linq.Mapping.XmlMappingSource.FromStream(contextStream);
            contextStream.Close();
Now, i know that there is a special constructor in the datacontext class which takes a MappingSource parameter but i don't want to use that because i don't want to bulk change all my code references and revert back if a problem arises. So, i changed the private static variable where you load once and keep the mappingsource, from:

Code: Select all

private static readonly MappingSource mappingSource = new AttributeMappingSource();
to:

Code: Select all

private static readonly MappingSource mappingSource = ServerSessionRegistry.MappingSource;
and in this way, a simple change to my static property feeds the datacontext with the appropriate mappingsource.

crazypit
Posts: 163
Joined: Wed 15 Apr 2009 08:43

Post by crazypit » Tue 11 Jan 2011 10:16

Anything new on that?

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Tue 11 Jan 2011 10:25

I've sent you a simple project in a letter, please check that it was not blocked. In the sample, a DataContext class designed in the way you've described is created several times. Please specify what should be changed in the sample to reproduce the problem, or send us your test project.

crazypit
Posts: 163
Joined: Wed 15 Apr 2009 08:43

Post by crazypit » Tue 11 Jan 2011 11:36

I recently switched from dotConnect for Oracle to LinqConnect and it seems that my lqml file is messed up. Using the latest version of Entity Developer 3.0.60, my lqml file does not open and no errors are reported. Using version 3.0.50, it opens. I will send you my lqml file through the support page and i would be obliged if you could fix it.

Maybe you can find the problem with the file mapping.

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Thu 13 Jan 2011 16:40

Thank you for the model. We've reproduced the issue for the DataContext class with external mapping generated for this .lqml. We will investigate the situation and inform you about the results as soon as possible.

As for the problem with opening the model, please try performing the following:
- uninstall both dotConnect for Oracle and LinqConnect;
- remove all Devart.* and policy.*.Devart.* assemblies from the GAC;
- clear the 'Program Files\Devart\dotConnect' and 'Program Files\Common Files\Devart' folders;
- install the latest version of dotConnect for Oracle or LinqConnect; please ensure that integration with Visual Studio is enabled in the install wizard.

If the problem persists, please try attaching to Entity Developer with Visual Studio (Tools -> Attach to Process) and catching the exceptions thrown (if any).

crazypit
Posts: 163
Joined: Wed 15 Apr 2009 08:43

Post by crazypit » Fri 14 Jan 2011 09:23

Done all of the above, and the lqml still does not open. I attached Visual Studio and no exceptions are thrown...

Same behavior encountered in other 3 workstations. No developer can open the file...

LinqConnect version 2.00.10.

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Mon 17 Jan 2011 18:03

Could you please describe the issue in more details? I.e., please specify
- how exactly you are opening the model (e.g., from Solution Explorer in Visual Studio, from Windows Explorer, or via the File -> 'Open Model' item of Entity Developer);
- what exactly occurs after opening the model (e.g., nothing, or model is opened in the XML editor, or the designer does not respond for a long time).
We were able to successfully open the model you've sent us with the latest 3.0.65 version of Entity Developer.

As for attaching with Visual Studio, please check that
- the 'Common Language Runtime Exceptions' check box is enabled in the Debug -> Exceptions dialog;
- the 'Enable Just My Code' check box in the Debugging section of Tools -> Options is disabled.

crazypit
Posts: 163
Joined: Wed 15 Apr 2009 08:43

Post by crazypit » Tue 18 Jan 2011 08:35

I forgot to disable the Just My Code parameter.

I get 2 System.NotSupportedException exceptions : Keyword not supported: 'sid', 'direct'
at Devart.Data.Oracle.OracleConnectionStringBuilder.a(String A_0)

I removed the entries from the Connection String and the model opened.

Nevertheless, i didn't put those entries in there my hand! How come Entity Developer do not recognize them? I guess the problem was that i created the first version of lqml file many versions ago and when i recently tried to reopen it, backward compatibility had a problrm to work properly.

And the thing that you say, that you can open the file without any problem!!!

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Tue 18 Jan 2011 17:57

Apparently, this .lqml file was created with the Professional edition or trial of dotConnect for Oracle, where the Direct mode is available. If LinqConnect only (which does not support the Direct mode) is installed on the machine, these keywords may fail to be recognized.

Thank you for your assistance, we will analyze the possibility of changing this behaviour (e.g., providing a message that the connection string is invalid).

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Fri 21 Jan 2011 16:46

We have fixed the problem with repeated creation of DataContext with external mapping. Also, we've changed the behaviour when opening a model with unsupported connection string parameters (e.g., 'Direct'): now such models should be opened, and a message of invalid parameter should be shown.

These changes will be available in the nearest build which we plan to release in about a week.

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Thu 27 Jan 2011 18:08

We have released the new 2.20.11 version of LinqConnect. The new build includes the fixes for the issues with
- repeated creation of DataContext with external mapping
- opening models with connection strings that include unsupported keywords.

The new build can be downloaded from
http://www.devart.com/linqconnect/download.html
(the trial and free versions) or from Registered Users' Area (for users with active subscription only):
http://secure.devart.com/

For the detailed information about the fixes and improvements available in LinqConnect 2.20.11, please refer to
http://www.devart.com/forums/viewtopic.php?t=20121

Post Reply