我很难调试服务。
我将从解释我正在运行的中心开始。 我使用他们的服务导入,几代报告和导出数据获得了9个数据库。 它们都可以运行一两天,但是当有一个新的数据库连接时,亚音速开始提供异常,所有异常都是simillar,只是更改数据库操作,有一个例子:
Probable I/O race condition detected while copying memory. The I/O package is not thread safe by default. In multithreaded applications, a stream must be accessed in a thread-safe way, such as a thread-safe wrapper returned by TextReader's or TextWriter's Synchronized methods. This also applies to classes like StreamWriter and StreamReader.
at System.Buffer.InternalBlockCopy(Array src, Int32 srcOffsetBytes, Array dst, Int32 dstOffsetBytes, Int32 byteCount)
at System.IO.StreamWriter.Write(Char[] buffer, Int32 index, Int32 count)
at System.IO.TextWriter.WriteLine(String value)
at System.IO.TextWriter.WriteLine(String format, Object arg0)
at System.IO.TextWriter.SyncTextWriter.WriteLine(String format, Object arg0)
at SubSonic.DataProviders.DbDataProvider.ExecuteReader(QueryCommand qry) in C:\[path]\SubSonic.Core\DataProviders\DbDataProvider.cs:line 112
at SubSonic.Linq.Structure.DbQueryProvider.Execute[T](QueryCommand`1 query, Object[] paramValues) in C:\[path]\SubSonic.Core\Linq\Structure\DbQueryProvider.cs:line 280
at lambda_method(Closure )
at SubSonic.Linq.Structure.DbQueryProvider.Execute(Expression expression) in C:\[path]\SubSonic.Core\Linq\Structure\DbQueryProvider.cs:line 131
at SubSonic.Linq.Structure.QueryProvider.System.Linq.IQueryProvider.Execute(Expression expression) in C:\[path]\SubSonic.Core\Linq\Structure\QueryProvider.cs:line 50
at SubSonic.Linq.Structure.Query`1.GetEnumerator() in C:\[path]\SubSonic.Core\Linq\Structure\Query.cs:line 85
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at [namespace].ReportManager.GetAllPending() in [path]\ReportManager.cs:line 193
at [namespace].ReportsServiceHandler.Run() in C:\[path]\ReportsServiceHandler.cs:line 137
到目前为止我唯一的解决方案是重置服务,但我还没有发现可能导致这种情况的原因。我尝试在我的本地环境中调试它,但我无法做到。
任何人都知道亚音中是否存在错误,或者如何在服务中找到问题?
提前感谢您的帮助。
答案 0 :(得分:0)
subsonics3让读者回复,你可以按照
的方式处理它Logger.info("this is a log")
使用(SqlDataReader reader = command.ExecuteReader()) { ......做你的东西...... }
我认为您需要使用Query qry = Product.CreateQuery().WHERE("ListPrice > 50.00")
.AND("Class = L").AND("Color = Yellow");
using(IDataReader rdr = qry.ExecuteReader())
{
while (rdr.Read()) {
Console.WriteLine(rdr[Product.Columns.Name].ToString());
}
}
来正确处理您的连接,因为您之前使用的连接可能仍然打开,即未关闭。
using
以上代码处理您的连接。或者如果不存在,我建议使用Dispose Pattern并在使用后处理连接对象。