Beispiel #1
0
 public SqlCeConnection()
 {
     NativeMethods.LoadNativeBinaries();
     dataSource         = string.Empty;
     isHostControlled   = false;
     weakReferenceCache = new ObjectLifeTimeTracker(true);
     NativeMethods.DllAddRef();
     isNativeAssemblyReleased = 0;
 }
Beispiel #2
0
 protected override void Dispose(bool disposing)
 {
     if (!isDisposed)
     {
         if (HasDelegatedTransaction)
         {
             if (disposing)
             {
                 isDisposed = true;
                 state      = ConnectionState.Closed;
                 if (weakReferenceCache != null)
                 {
                     weakReferenceCache.CloseDataRdr(null);
                 }
             }
         }
         else
         {
             if (disposing)
             {
                 if (isOpened)
                 {
                     try {
                         OnStateChange(ConnectionState.Open, ConnectionState.Closed);
                     } catch (Exception e) {
                         if (!ADP.IsCatchableExceptionType(e))
                         {
                             throw;
                         }
                     }
                 }
                 if (weakReferenceCache != null)
                 {
                     weakReferenceCache.Close(true);
                     weakReferenceCache = null;
                 }
                 connStr         = null;
                 dataSource      = null;
                 modifiedConnStr = null;
                 isOpened        = false;
                 isDisposed      = true;
                 state           = ConnectionState.Closed;
             }
             if (!isHostControlled)
             {
                 ReleaseNativeInterfaces();
             }
             if (Interlocked.Exchange(ref isNativeAssemblyReleased, 1) == 0)
             {
                 NativeMethods.DllRelease();
             }
             base.Dispose(disposing);
         }
     }
 }