cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Bug in iAnywhere.Data.SQLAnywhere.v4.0.dll

Former Member
7,522

Exception message:

[NullReferenceException: Object reference not set to an instance of the object.]
   iAnywhere.Data.SQLAnywhere.SAConnection.CalledByEntityFramework() +263
   iAnywhere.Data.SQLAnywhere.SAConnection.get_ConnectionString() +538
   Dapper.Identity..ctor(String sql, Nullable`1 commandType, IDbConnection connection, Type type, Type parametersType, Type[] otherTypes) +73
   Dapper.<QueryInternal>d__13`1.MoveNext() +545
   System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +381
   System.Linq.Enumerable.ToList(IEnumerable`1 source) +58
   Dapper.SqlMapper.Query(IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Boolean buffered, Nullable`1 commandTimeout, Nullable`1 commandType) +218
   Dapper.SqlMapper.Query(IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Boolean buffered, Nullable`1 commandTimeout, Nullable`1 commandType) +88

Everything works fine until sybase create fix v 12.3457 and in 16 version nothing chcanges - the same error! I look into connection object in debug. In _connStr property cinnection string is right, but in + ConnectionString I see exception message - 'cn.ConnectionString' threw an exception of type 'System.NullReferenceException' string {System.NullReferenceException}

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member

In CalledByEntityFramework() the declaringType can also be null.

private bool CalledByEntityFramework()
{
    string[] strArray = new string[] { "System.Data.Entity" };
    StackTrace trace = new StackTrace();
    for (int i = 0; i < trace.FrameCount; i++)
    {
            //The declaringType variable may be null here
        Type declaringType = trace.GetFrame(i).GetMethod().DeclaringType;
        foreach (string str in strArray)
        {
            if ((declaringType.FullName != null) && declaringType.FullName.StartsWith(str, StringComparison.InvariantCultureIgnoreCase))
            {
                return true;
            }
        }
    }
    return false;
}

The function should be change as following (added a null-check for declaringType)

private bool CalledByEntityFramework()
{
    string[] strArray = new string[] { "System.Data.Entity" };
    StackTrace trace = new StackTrace();
    for (int i = 0; i < trace.FrameCount; i++)
    {
        Type declaringType = trace.GetFrame(i).GetMethod().DeclaringType;
            if (declaringType != null) {
               foreach (string str in strArray)
                {
                  if ((declaringType.FullName != null) && declaringType.FullName.StartsWith(str, StringComparison.InvariantCultureIgnoreCase))
                  {
                    return true;
                  }
                }
            }
    }
    return false;
}
jeff_albion
Product and Topic Expert
Product and Topic Expert

Update 3: The second issue in this thread has been fixed in CR #738144, in builds 11.0.1.2976, 12.0.1.3893, 16.0.0.1524


Update 2: I have reproduced the second issue reported in this thread and have opened CR #738144 to investigate further.


Update: This issue is now fixed in CR #735130, builds 11.0.1.2957, 12.0.1.3873, and 16.0.0.1485


I concur - this seems to be a bug in our driver, specifically with generic type arguments. I have opened this issue as CR #735130.

I will update this thread as we learn more about this behaviour.

Former Member
0 Kudos

Thanks a lot! Pls. Tell me where I can see this case

jeff_albion
Product and Topic Expert
Product and Topic Expert
0 Kudos

Do you have a technical support plan with us? If so, please let me know the case number and I will associate this bug fix to it and we can let you know regarding further updates. (You can e-mail me at firstname.lastname@sap.com where firstname = jeff, lastname = albion). We can also discuss the priority of the fix and any business case you may have to fix it with priority in the context of the technical support case.

See:

http://www.sybase.com/contactus/support/ (for existing Sybase Customers)

http://www.sap.com/services-and-support/support/ (for new SAP customers)

If you do not have a support plan, this bug will be fixed as resources and time allow (since this is currently submitted underneath our non-priority 'submit a bug' queue).

Thank you for the bug submission.

Former Member
0 Kudos

Hi. You said that this bug will be resolved in ebf 3873, but nothing has changed (.

iAnywhere.Data.SQLAnywhere.SAConnection.CalledByEntityFramework() +427

iAnywhere.Data.SQLAnywhere.SAConnection.get_ConnectionString() +1032 Dapper.Identity..ctor(String sql, Nullable1 commandType, IDbConnection connection, Type type, Type parametersType, Type[] otherTypes) +278 Dapper.<QueryInternal>d__131.MoveNext() +767 System.Collections.Generic.List1..ctor(IEnumerable1 collection) +846 System.Linq.Enumerable.ToList(IEnumerable1 source) +133 Dapper.SqlMapper.Query(IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Boolean buffered, Nullable1 commandTimeout, Nullable1 commandType) +476 Dapper.SqlMapper.Query(IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Boolean buffered, Nullable1 commandTimeout, Nullable`1 commandType) +340

Former Member
0 Kudos

Can you test it with some test proj?

jeff_albion
Product and Topic Expert
Product and Topic Expert
0 Kudos

Not currently, no. I don't have enough information to currently understand your reproducible environment.

  • Is this only reproducible running in an ASP.NET context? On IIS 7/8? .NET Framework 4/4.5?
  • Can you confirm that 'Dapper' you're referring to is this project here: http://code.google.com/p/dapper-dot-net/source/browse/Dapper/ ?
  • Can you provide the full Dapper project code you're using, including the .Query() call?

I've never used Dapper myself, particularly on ASP.NET, so you're going to need to provide myself some easy-to-run examples for me to set up Dapper and reproduce it.

Or you can open a technical support case and we can work with you directly to ensure your particular environment and issue is addressed.

Former Member
0 Kudos

It's test simple project in VS 2012 asp.net mvc 4. I wrote to dapper's developers they said that bug was in SAConnection class. Yes this link for dapper - http://code.google.com/p/dapper-dot-net/source/browse/Dapper/

I've never used Dapper myself, particularly on ASP.NET, so you're going to need to provide myself some easy-to-run examples for me to set up Dapper and reproduce it.

ok - do I need place code right here or send you a project?

jeff_albion
Product and Topic Expert
Product and Topic Expert
0 Kudos

The best thing to do is to open a technical support case and we can provide direct instructions to you on how to provide us with these files.

If the code / setup instructions are very short, you can post them here and I can try to reproduce the issue when I get a chance - someone else at SAP may be able to do the same if your instructions are clear enough.

Otherwise, you can submit a project/reproduction instructions via the 'Create Bug Report Case' through the non-priority service on Case-Express and we will take a look at the issue as time allows.

Former Member
0 Kudos

Ok here is my code. I use simple demo db - SQL Anywhere 12 Demo and default ASP.NET.MVC 4 app + Dapper.net 1.8.0 from nuget package,sybase 12.0.1 ebf 3873, Windows 7 Ultimate sp1. I also work with mysql with dapper - works fine, no problem any version!

You need to add reference to iAnywhere.Data.SQLAnywhere.v4.0.dll and Dapper.net

web.config:

<connectionStrings>
<add name="ApplicationServices" connectionString="DSN=SQL Anywhere 12 Demo;"    providerName="iAnywhere.Data.SQLAnywhere"/>
</connectionstrings>

HomeController:

private BaseDapperRepository _db;
protected override void Initialize(RequestContext requestContext)
    {
        if(_db == null)
            _db = new BaseDapperRepository();

        base.Initialize(requestContext);
    }
public ActionResult Index()
    {
        ViewBag.Message = "Modify this template to kick-start your ASP.NET MVC application.";

        var rep1 = _db.GetIds();

        return View();
    }

BaseDapperRepository - it is class that works with db

private readonly ConnectionStringSettings _connectionSettings = ConfigurationManager.ConnectionStrings["ApplicationServices"];

       public class BaseDapperRepository : IDisposable
{
       protected DbConnection MDbConnection;
       public BaseDapperRepository()
       {
            var providerFactory = DbProviderFactories.GetFactory(_connectionSettings.ProviderName);

            MDbConnection = providerFactory.CreateConnection();
            if(MDbConnection == null)
                throw new Exception("Error while creating connetion to DB");
            MDbConnection.ConnectionString = _connectionSettings.ConnectionString;
       }
public dynamic GetIds()// test method, returns dynamic objs
       {
           dynamic result;

           using (MDbConnection)
           {

               MDbConnection.Open();

               const string sql = @"ShowCustomers";

               result = MDbConnection.Query(sql, commandType: CommandType.StoredProcedure);

               MDbConnection.Close();
           }    
           return result;
       }
public void Dispose()
        {
           MDbConnection.Dispose();
        }

}

Former Member
0 Kudos

I said that I' wrote to Dapper developers, here their answer:

Principally, this sounds like a bug in that specific ADO.NET implementation. The error is coming from inside a 3rd party component. The best I can suggest is: report it to them.

We use the connection-string to provide back-end specific structural caching; we know that many sites have similar (but not always the same) structures on multiple databases. The only other thing we can do is to look more at the structure itself - I'll check if we hash that currently.

So before that build(ebf 3457) iAnywhere does not loose connection string

Former Member
0 Kudos

Please write answer if you try to reproduce this bug

Former Member
0 Kudos

Hi! So are you going to make changes in iAnywhere.Data.SQLAnywhere.v4.0.dll for 12 version or for 16 version of iAnywhere in some next EBF update?

VolkerBarth
Contributor

You may have a look at the according CR description here, as Jeff has noted:

http://search.sybase.com/kbx/changerequests?bug_id=738144

Given that, the fix is contained in builds 16.0.0.1524, 12.0.1,3893 and 11.0.1.2976 and above.

Former Member
0 Kudos

Thanks, so I'm wating for the new EBF(they shuold appear in the end of may?)

jeff_albion
Product and Topic Expert
Product and Topic Expert
0 Kudos

The EBF will be released when it has completed our QA process - we do not offer specific dates for when EBFs will be released. You can sign up to our EBF page to be notified when a new EBF is released, or you can open a technical support case to let us know about your particular business priority for this fix and we can work with you to notify you immediately when this EBF release is ready.

Former Member
0 Kudos

Thanks, I'll be waiting for the patch

Breck_Carter
Participant
0 Kudos

12.0.1.3894 just got shipped for IBM AIX, HP UX and Solaris, but not Windows... since it has been over a month since the last 12.0.1 EBF for Windows, one is "due any minute now" so stay tuned.

Alas, 16.0.0.1512 just got shipped so V16 probably won't see this fix for a while.

Former Member
0 Kudos

I see that the bugfix is enabled - 3895 - http://downloads.sybase.com/swd/summary.do?client=support&baseprod=144.(SQL Anywhere - Express Bug Fix, Update of 12.0.1 to build 3895 12.0.1 28 May 2013 EBF/Patch) Does this mean that my problem is fixed too?

jeff_albion
Product and Topic Expert
Product and Topic Expert
0 Kudos

CR #738144 is fixed in 12.0.1.3893. EBFs are cumulative, so yes, this fix is included in 12.0.1.3895.

Have you tried this EBF?

Former Member

Yohooo! Everything works fine! Thanks!

VolkerBarth
Contributor
0 Kudos

Glad to hear that:)

FWIW, if that answer by Jeff has helped you, you're invited to mark it as accepted - cf. How do I accept an answer to my question?...

Ask a Question