Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Bug in VS 2013?
Message
From
03/05/2014 03:18:15
 
General information
Forum:
ASP.NET
Category:
Troubleshooting
Title:
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01599384
Message ID:
01599486
Views:
37
>>>>What's middlewareMain ?
>>>
>>>It is a public class in another project
>>>
>>>
>>>   public class MiddlewareMain : MiddlewareBase
>>>   {
>>>      private delegate String InvokeMethod(Dictionary<String, String> parameters);
>>>      private Dictionary<String, InvokeMethod> invokeMethods;
>>>      private Sales _sales;
>>>      private Data _data;
>>>      private Retail _retail;
>>>      private Bookings _bookings;
>>>      private Validation _validation;
>>>      private Boolean _bShouldRollback             = false;
>>>      private Boolean _bShouldRollbackGlobalInvoke = false;
>>>
>>>...
>>>
>>>
>>>In the Test class used as a base for other test classes I see the following code:
>>>
>>>
>>> public abstract class UnitTestBase
>>>   {
>>>      public static IniFile iniFile, systemIniFile;
>>>      public static MiddlewareMain middlewareMain;
>>>      public static Boolean isClassInitialized = false;
>>
>>Actually you appear to be calling middlewareMain.Invoke(cInvoke);
>>
>>I only see a InvokeMethod() method?
>
>I didn't post the whole thing yet :)
>
>
>      /// <summary>
>      /// Main Invoke method
>      /// </summary>
>      /// <param name="input"></param>
>      /// <returns></returns>
>      public String Invoke(String input)
>      {
>         this.CurrentRequest = new Request();
>         this.CurrentRequest.InvokeString = input; // Save invoke string
>         Logging.Log(2, "Invoke called with " + input);
>         this.CurrentRequest.InvokeStartTime = DateTime.Now;
>
>         this.data.CurrentRequest = this.CurrentRequest;
>         this.sales.CurrentRequest = this.CurrentRequest;
>         this.bookings.CurrentRequest = this.CurrentRequest;
>         this.validation.CurrentRequest = this.CurrentRequest;
>         this.retail.CurrentRequest = this.CurrentRequest;
>
>         Dictionary<String, String> parameters = new Dictionary<String, String>(StringComparer.OrdinalIgnoreCase);
>
>         try
>         {
>            parameters.PopulateFromSQML(input);
>         }        
>         
>         catch (Exception ex)
>         {
>            String error = ex.ToString();
>            Logging.Log(error, 1);
>            this.CurrentRequest.LastError = new ErrorState(100, error);            
>         }
>
>         if (this.CurrentRequest.LastError ==null && !parameters.ContainsKey("func"))
>         {
>            this.CurrentRequest.LastError = new ErrorState(100, "Parameter 'func' not specified");          
>         }
>
>         if (this.CurrentRequest.LastError == null && !invokeMethods.ContainsKey(parameters["func"]))
>         {
>            this.CurrentRequest.LastError = new ErrorState(100, String.Format("Function '{0}' is not available", parameters["func"]));            
>         }
>
>         if (this.CurrentRequest.LastError != null)
>         {            
>            return this.CurrentRequest.FormatError();
>         }
>         String cReturnValue = "";
>       
>         // If the <TestOnly> tag was passed in the Invoke call, roll back the entire Invoke call once it completes (see below)
>         if (parameters.ContainsKey("testonly"))
>            database.rollbackGlobalInvoke = true;
>
>         try
>         {
>            if (database.rollbackGlobalInvoke)
>            {
>               using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions() { IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted }))
>               {
>                  database.globalTransaction = true;
>                  if (database.sqlConnection != null && database.sqlConnection.State == ConnectionState.Open)
>                     database.sqlConnection.EnlistTransaction(Transaction.Current);
>                  cReturnValue = invokeMethods[parameters["func"]](parameters);
>                  database.globalTransaction = false;
>                  // Do not call Complete(), so the entire Invoke call will be automatically rolled back.
>                  // scope.Complete();   
>               }
>            }
>            else
>               cReturnValue = invokeMethods[parameters["func"]](parameters);
>         }
>
>         catch (SiriusException ex)
>         {
>            Logging.LogFormat(1,"Sirius Exception Caught: {0}", ex.Message);
>            this.CurrentRequest.LastError = new ErrorState((Int16)ex.statusCode, ex.Message);
>            // Lookup error codes for the status returned if necessary.
>            cReturnValue = this.CurrentRequest.FormatError();
>         }
>
>         catch (Exception ex)
>         {
>            String error = ex.ToString();
>            Logging.Log(error, 1);
>            this.CurrentRequest.LastError = new ErrorState(100, error);
>            cReturnValue = this.CurrentRequest.FormatError();
>         }
>         
>         this.CurrentRequest.InvokeEndTime = DateTime.Now;
>         Logging.Log(2, "Invoke took " + this.CurrentRequest.InvokeDuration.ToString());
>         this.CurrentRequest.Dispose();
>         return cReturnValue;
>      }
>   }
I see the Request class implements IDisposable so it's presumably accessing unmanaged resources - and the above code doesn't guarantee that Dispose() is called. Might just be possible that it's holding something open that the compiler needs. IAC you should wrap it in a using block.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform