1

时不时地,当我进行数据库查询时,我会ExecuteNonQueryMySQL.Data库中遇到问题。

在此处输入图像描述

引发的异常是:

Exception thrown: 'System.ArgumentOutOfRangeException' in CommonLanguageRuntimeLibrary ("Length cannot be less than zero.")

我有来自Azure Worker Role的IntelliTrace的日志。

它在大多数情况下都有效,但是当发生这种情况时,它会停止工作人员的正常处理。

我正在从 加载连接字符串app.config,它看起来像这样:

<add key="DatabaseConnectionString" value="Server=localhost; Port=3306; Uid=user; Pwd=mypassword; Pooling=false;" />

我在运行时为每个请求选择数据库,因为它不断更改它连接到的数据库。

我能做些什么来阻止这种情况发生并允许新连接正确打开吗?

编辑

在进一步调查和爬取MySQL.Data 源代码后,我深入研究了这个getter.

    [DisplayName("program_name")]
    public string ProgramName
    {
      get
      {
        string name = Environment.CommandLine;
        try
        {
          string path = Environment.CommandLine.Substring(0, Environment.CommandLine.IndexOf("\" ")).Trim('"');
          name = System.IO.Path.GetFileName(path);
          if (Assembly.GetEntryAssembly() != null)
            name = Assembly.GetEntryAssembly().ManifestModule.Name;
        }
        catch (Exception ex)
        {
          name = string.Empty;
          System.Diagnostics.Debug.WriteLine(ex.ToString());
        }
        return name;
      }
    }

现在WorkerRole是否有可能在执行期间的某个时间开始为Environment.CommandLine属性返回不同的值?这似乎正在发生,因为它在开始时有效,然后在一段时间后(2-3 天)失败。

4

0 回答 0