Specified cast is not valid (v7.4.146.0)

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
Nylle
Posts: 4
Joined: Fri 25 Jan 2013 15:27

Specified cast is not valid (v7.4.146.0)

Post by Nylle » Fri 25 Jan 2013 15:51

Hello,

I'm completely new to Devart and looked over the FAQ and searched the forum. I found a lot of posts regarding the bug with the "Specified cast is not valid" exception when searching for an entity. Apparently this has been fixed in version 7.3, however I get this exception every time I submit any changes to the data context.

I just inherited a huge project using dotConnect. Due to infrastructure changes I had to migrate from version 5.2.5 to 7.4.146.0 and since migration I get the following exception, whenever I submit any changes to the context (in this case I try to delete from a table):

Code: Select all

Specified cast is not valid.
   at Devart.Data.Oracle.OracleUtils.a(Object A_0, OracleDbType A_1, Boolean A_2)
   at Devart.Data.Oracle.OracleParameter.e(Object A_0)
   at Devart.Data.Oracle.OracleParameter.get_OracleValue()
   at E247.CMS.Web.Global.oracleMonitor1_TraceEvent(Object sender, MonitorEventArgs e) in Global.asax.cs:line 45
   at Devart.Common.DbMonitor.OnTraceEvent(Object sender, MonitorEventArgs e, Boolean parentMessage)
My client code is like:

Code: Select all

context.LmCategories.DeleteOnSubmit(lmCategory);
context.SubmitChanges();
Then oracleMonitor1_TraceEvent in my Global.asax is called with the following command:

Code: Select all

DELETE FROM MUSIC_247.LM_CATEGORIES WHERE CATEGORY_ID = :key1 
AND ATTACH_ID = :key2 
AND SEQ_NO = :chk1 
AND ((:nullchk2 = 1 AND TEXT_ID IS NULL) OR (TEXT_ID = :chk2)) 
AND ((:nullchk3 = 1 AND FILTER_TYPE IS NULL) OR (FILTER_TYPE = :chk3)) 
AND ((:nullchk4 = 1 AND FILTER_VALUE IS NULL) OR (FILTER_VALUE = :chk4))
in line 4 the :nullchk2 parameter throws with 'param.OracleValue' threw an exception of type 'System.InvalidCastException'

DbType is Int32
OracleDbType is Integer

I have the feeling, that this is not a bug in dotConnect, but in our code, but I have no experience with Devart so far and don't know where the command comes from in the first place.

Any tips or hints?

Greetings,
Jan

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Specified cast is not valid (v7.4.146.0)

Post by MariiaI » Mon 28 Jan 2013 11:31

We couldn't reproduce this issue on our environment with dotConnect for Oracle versions 7.4.146 and 7.5.164. We are sending you a sample project to the e-mail address you provided in your forum profile. Please make changes to it so that the issue could be reproduced and send it back to us or send us your project/model.

Also, please make sure that the assemblies with correct versions are added to your project(e.g., in the Solution Explorer->Your Project->Referenсes or in the Debug->Windows->Modules when debugging your project):
- Devart.Data - 5.0.605;
- Devart.Data.Oracle - 7.4.146;
- Devart.Data.Linq and Devart.Data.Oracle.Linq - 4.1.151.

Looking forward to your reply.

Nylle
Posts: 4
Joined: Fri 25 Jan 2013 15:27

Re: Specified cast is not valid (v7.4.146.0)

Post by Nylle » Tue 29 Jan 2013 12:19

Hi, I checked the versions and they are the same as specified by you. Furthermore I was able to reproduce the issue in your sample project after I did a couple of changes. I sent it back to you.

The changes are just the adding of a Devart.Data.Oracle.OracleMonitor and adding of a TraceEvent. When the changes to model are submitted, this trace event will be called back. By using the Devart.Data.Oracle.OracleCommand I try to analyze the query string and the Devart.Data.Oracle.OracleParameter throws as described before.

Code: Select all

protected static Devart.Data.Oracle.OracleMonitor oracleMonitor1;
protected Devart.Data.Oracle.OracleTrace oracleTrace;

static void Main(string[] args) {
    oracleMonitor1 = new Devart.Data.Oracle.OracleMonitor { IsActive = true };
    oracleMonitor1.TraceEvent += new MonitorEventHandler(oracleMonitor1_TraceEvent);

    TestDataContext dc = new TestDataContext() { Log = Console.Out };
    Int32 ArticleVersionID = 1;
    var first = dc.TestLongs.First(tl => tl.Id == ArticleVersionID);
    dc.TestLongs.DeleteOnSubmit(first);
    dc.SubmitChanges();
}

private static void oracleMonitor1_TraceEvent(object sender, MonitorEventArgs e) {
    if (e.EventType.ToString() == "Execute" && e.TracePoint.ToString() == "AfterEvent") {
        var cmd = (OracleCommand) sender;
        if (cmd != null) {
            string parameterBuilder = "";
            foreach (OracleParameter param in cmd.Parameters) {
                parameterBuilder += param.ParameterName + " = " + param.OracleValue.ToString() + "(" +
                param.OracleDbType + "); ";
            }
        }
    }
}
Thanks for your help,
Jan

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Specified cast is not valid (v7.4.146.0)

Post by MariiaI » Wed 30 Jan 2013 07:19

Thank you for the additional information. We have reproduced this issue. We will investigate it and inform you about the results as soon as possible.

Nylle
Posts: 4
Joined: Fri 25 Jan 2013 15:27

Re: Specified cast is not valid (v7.4.146.0)

Post by Nylle » Wed 30 Jan 2013 07:43

Thanks a lot!

Nylle
Posts: 4
Joined: Fri 25 Jan 2013 15:27

Re: Specified cast is not valid (v7.4.146.0)

Post by Nylle » Sat 09 Feb 2013 13:23

Hello,

are there any news on this issue? Is there a workaround available yet?

Greetings,
Jan

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Specified cast is not valid (v7.4.146.0)

Post by MariiaI » Tue 12 Feb 2013 08:44

We are investigating this issue at the moment. We will inform you about the results in the near future.

Post Reply