本文整理汇总了C#中System.Diagnostics.StackTrace.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# System.Diagnostics.StackTrace.ToString方法的具体用法?C# System.Diagnostics.StackTrace.ToString怎么用?C# System.Diagnostics.StackTrace.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Diagnostics.StackTrace
的用法示例。
在下文中一共展示了System.Diagnostics.StackTrace.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LogFunc
static void LogFunc (string logDomain, GLib.LogLevelFlags logLevel, string message)
{
if (RemainingBytes < 0)
return;
System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace (2, true);
string msg = string.Format ("{0}-{1}: {2}\nStack trace: \n{3}",
logDomain, logLevel, message, trace.ToString ());
switch (logLevel) {
case GLib.LogLevelFlags.Debug:
LoggingService.LogDebug (msg);
break;
case GLib.LogLevelFlags.Info:
LoggingService.LogInfo (msg);
break;
case GLib.LogLevelFlags.Warning:
LoggingService.LogWarning (msg);
break;
case GLib.LogLevelFlags.Error:
case GLib.LogLevelFlags.Critical:
default:
LoggingService.LogError (msg);
break;
}
RemainingBytes -= msg.Length;
if (RemainingBytes < 0)
LoggingService.LogError ("Disabling glib logging for the rest of the session");
}
示例2: LogFunc
static void LogFunc(string logDomain, GLib.LogLevelFlags logLevel, string message)
{
System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace (2, true);
string msg = string.Format ("{0}-{1}: {2}\nStack trace: {3}{4}",
logDomain, logLevel, message, Environment.NewLine, trace.ToString ());
switch (logLevel) {
case GLib.LogLevelFlags.Debug:
Log.Debug (msg);
break;
case GLib.LogLevelFlags.Info:
Log.Info (msg);
break;
case GLib.LogLevelFlags.Warning:
Log.Warn (msg);
break;
case GLib.LogLevelFlags.Error:
Log.Error (msg);
break;
case GLib.LogLevelFlags.Critical:
default:
Log.Fatal (msg);
break;
}
}
示例3: Open
/// <summary>
/// Opens the specified filename
/// </summary>
protected void Open(string filename, string fileMode)
{
// sanity check
if (IsOpen)
{
throw new ApplicationException("ERROR: The Open method was called even though the file is already open.");
}
FileStreamPointer = SafeNativeMethods.gzopen(filename, fileMode);
if (FileStreamPointer == IntPtr.Zero)
{
//for some reason throwing an exception here can hang. Possibly from the managed to native transition?
//if you encounter that you should check for the complicating condition before trying to open the gzip file and handle it accordingly
//you may have to call Environment.Exit(-1) as throwing an exception may hang
//interestingly enabling native code debugging is a workaround but that won't work outside Visual Studio
Console.Error.WriteLine(string.Format("ERROR: Unable to open the file ({0}) for reading", filename));
Console.Error.WriteLine("This process will now exit");
System.Diagnostics.StackTrace t = new System.Diagnostics.StackTrace();
Console.Error.WriteLine(t.ToString());
System.Environment.Exit(-1);
}
FilePath = filename;
IsOpen = true;
CurrentOffset = 0;
BufferOffset = 0;
}
示例4: HealthCheck
public static void HealthCheck(Action healthyBehaviour)
{
var currentStack = new System.Diagnostics.StackTrace();
Application.Current.Dispatcher.BeginInvoke((Action)delegate
{
try
{
foreach (var server in SERVERS)
server.ok = false;
checkServers();
int attempts = 0;
const int MILIS_BETWEEN_TRIES = 500;
var timer = new DispatcherTimer(TimeSpan.FromMilliseconds(MILIS_BETWEEN_TRIES), DispatcherPriority.Normal,
(sender, args) =>
{
var brokenServers = SERVERS.Where(s => !s.ok);
attempts++;
if (brokenServers.Count() == 0)
{
self.Visibility = Visibility.Collapsed;
((DispatcherTimer)sender).Stop();
healthyBehaviour();
}
}, Application.Current.Dispatcher);
timer.Start();
}
catch (Exception e)
{
throw new Exception(currentStack.ToString(), e);
}
});
}
示例5: login
public void login()
{
if (validateLogin("lol", "lol2"))
{
System.Windows.Forms.MessageBox.Show("Logged in");
}
else
System.Windows.Forms.MessageBox.Show("Failed");
System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace ();
System.Windows.Forms.MessageBox.Show(stackTrace.ToString());
}
示例6: Debug
/// <summary>
/// Log a debug message with a stack trace.
/// </summary>
/// <param name="message">The message to log with the stack
/// trace.</param>
public static void Debug (String message) {
if (LOGGER.IsDebugEnabled) {
System.Diagnostics.StackTrace trace =
new System.Diagnostics.StackTrace ();
String msg = "";
if (null != message) {
msg = msg + "message=[" + message + "]";
}
msg = msg + "stackTrace=[" + trace.ToString () + "]";
LOGGER.Debug (msg);
}
}
示例7: AssetBase
public AssetBase(string assetID, string name, sbyte assetType)
{
if (assetType == (sbyte)AssetType.Unknown)
{
System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(true);
m_log.ErrorFormat("[ASSETBASE]: Creating asset '{0}' ({1}) with an unknown asset type\n{2}",
name, assetID, trace.ToString());
}
m_metadata = new AssetMetadata();
m_metadata.ID = assetID;
m_metadata.Name = name;
m_metadata.Type = assetType;
}
示例8: GetSolutionFolder
private static string GetSolutionFolder(string dllFilePath, StringBuilder sb)
{
var dll = new FileInfo(dllFilePath);
string solutionFolder = null;
if (dll.Directory?.Parent?.Parent?.Parent == null) // ...\Solution
{
sb.AppendLine("Checking for VSOnline");
sb.AppendLine(dll.DirectoryName);
if (dll.DirectoryName == @"C:\a\bin")
{
// Build is on VSOnline. Redirect to other c:\a\src\Branch Name
var s = new System.Diagnostics.StackTrace(true);
sb.AppendLine(s.ToString());
for (var i = 0; i < s.FrameCount; i++)
{
var fileName = s.GetFrame(i).GetFileName();
sb.AppendLine(fileName ?? String.Empty);
if (!String.IsNullOrEmpty(fileName))
{
// File name will be in the form of c:\a\src\Branch Name\project\filename. Get everything up to and including the Branch Name
var parts = fileName.Split(Path.DirectorySeparatorChar);
solutionFolder = Path.Combine(parts[0] + Path.DirectorySeparatorChar + parts[1], parts[2], parts[3]);
sb.AppendLine(solutionFolder);
break;
}
}
}
}
else
{
// Check for XUnit Temp Directory
if (dll.Directory.Parent.Parent.Parent.Name.ToLower() == "assembly" && dll.Directory.Parent.Parent.Name.ToLower() == "dl3")
{
// Return null and let recall happen with CodeBase rather than location
return null;
}
// ..\Solution\Project\bin\Build
solutionFolder = dll.Directory.Parent.Parent.Parent.FullName;
}
return solutionFolder;
}
示例9: LogFunc
static void LogFunc (string logDomain, GLib.LogLevelFlags logLevel, string message)
{
System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace (2, true);
string msg = string.Format ("{0}-{1}: {2}\nStack trace: \n{3}",
logDomain, logLevel, message, trace.ToString ());
switch (logLevel) {
case GLib.LogLevelFlags.Debug:
LoggingService.LogDebug (msg);
break;
case GLib.LogLevelFlags.Info:
LoggingService.LogInfo (msg);
break;
case GLib.LogLevelFlags.Warning:
LoggingService.LogWarning (msg);
break;
case GLib.LogLevelFlags.Error:
case GLib.LogLevelFlags.Critical:
default:
LoggingService.LogError (msg);
break;
}
}
示例10: GetFromPool4K
/// <summary>
/// 从缓冲池里获得数据
/// </summary>
/// <returns></returns>
public static DogBuffer GetFromPool4K()
{
lock (lockOjb)
{
start:
var ret = s_pools.AcquireContent();
if (ret.referenceCounter != 0)
{
Logs.Error("dog buffer4k is used. counter = {0}", ret.referenceCounter);
#if DEBUG
var stack = new System.Diagnostics.StackTrace(0);
Logs.Info("dog buffer is used. strace = {0}", stack.ToString());
#endif
goto start;
}
ret.Use();
//ret.referenceCounter++;
ret.Length = 0;
return ret;
}
}
示例11: GetFromPool32K
/// <summary>
/// 从缓冲池里获得数据
/// </summary>
/// <returns></returns>
public static DogBuffer32K GetFromPool32K()
{
lock (lockOjb)
{
start1:
var ret = s_pools32K.AcquireContent();
if (ret.referenceCounter != 0)
{
Logs.Error("dog buffer32 is used.");
//Logs.Error(string.Format("buff is exists {0} exitstCount={1}", exitsList.Contains(ret).ToString(), exitsList.Count));
#if DEBUG
var stack = new System.Diagnostics.StackTrace(0);
Logs.Error("dog buffer is used. strace = {0}", stack.ToString());
#endif
goto start1;
}
//exitsList.Add(ret);
//ret.referenceCounter++;
ret.Use();
ret.Length = 0;
return ret;
}
}
示例12: PopulateExceptionLog
/// <summary>
/// Populates the <see cref="Rock.Model.ExceptionLog" /> entity with the exception data.
/// </summary>
/// <param name="ex">The <see cref="System.Exception" /> to log.</param>
/// <param name="context">The <see cref="System.Web.HttpContext" />.</param>
/// <param name="pageId">An <see cref="System.Int32" /> containing the Id of the <see cref="Rock.Model.Page" /> where the exception occurred.
/// This value is nullable.</param>
/// <param name="siteId">An <see cref="System.Int32" /> containing the Id the <see cref="Rock.Model.Site" /> where the exception occurred.
/// This value is nullable.</param>
/// <param name="personAlias">The person alias.</param>
/// <returns></returns>
private static ExceptionLog PopulateExceptionLog( Exception ex, HttpContext context, int? pageId, int? siteId, PersonAlias personAlias )
{
int? personAliasId = null;
if (personAlias != null)
{
personAliasId = personAlias.Id;
}
string exceptionMessage = ex.Message;
if ( ex is System.Data.SqlClient.SqlException )
{
var sqlEx = ex as System.Data.SqlClient.SqlException;
var sqlErrorList = sqlEx.Errors.OfType<System.Data.SqlClient.SqlError>().ToList().Select(a => string.Format("{0}: Line {1}", a.Procedure, a.LineNumber));
if ( sqlErrorList.Any() )
{
exceptionMessage += string.Format( "[{0}]", sqlErrorList.ToList().AsDelimited(", ") );
}
}
var exceptionLog = new ExceptionLog
{
SiteId = siteId,
PageId = pageId,
HasInnerException = ex.InnerException != null,
ExceptionType = ex.GetType().ToString(),
Description = exceptionMessage,
Source = ex.Source,
StackTrace = ex.StackTrace,
Guid = Guid.NewGuid(),
CreatedByPersonAliasId = personAliasId,
ModifiedByPersonAliasId = personAliasId,
CreatedDateTime = RockDateTime.Now,
ModifiedDateTime = RockDateTime.Now,
ModifiedAuditValuesAlreadyUpdated = true
};
if ( exceptionLog.StackTrace == null )
{
try
{
// if the Exception didn't include a StackTrace, manually grab it
var stackTrace = new System.Diagnostics.StackTrace( 2 );
exceptionLog.StackTrace = stackTrace.ToString();
}
catch
{
// ignore
}
}
try
{
ex.Data.Add( "ExceptionLogGuid", exceptionLog.Guid );
}
catch
{
// ignore
}
try
{
// If current HttpContext is null, return early.
if ( context == null )
{
return exceptionLog;
}
// If current HttpContext is available, populate its information as well.
var request = context.Request;
StringBuilder cookies = new StringBuilder();
var cookieList = request.Cookies;
if ( cookieList.Count > 0 )
{
cookies.Append( "<table class=\"cookies exception-table\">" );
foreach ( string cookie in cookieList )
{
var httpCookie = cookieList[cookie];
if ( httpCookie != null )
cookies.Append( "<tr><td><b>" + cookie + "</b></td><td>" + httpCookie.Value.EncodeHtml() + "</td></tr>" );
}
cookies.Append( "</table>" );
}
StringBuilder formItems = new StringBuilder();
var formList = request.Form;
//.........这里部分代码省略.........
示例13: CancelWalking
public void CancelWalking()
{
#if LOG
System.Diagnostics.StackTrace t = new System.Diagnostics.StackTrace();
logger.Log(name + " canceled walking. Stack trace: " + t.ToString());
#endif
StopAction();
ClearWalkingData();
}
示例14: SendPacket
public void SendPacket(LLAgent agent, Packet packet, ThrottleCategory category, bool allowSplitting)
{
// CoarseLocationUpdate and AvatarGroupsReply packets cannot be split in an automated way
if ((packet.Type == PacketType.CoarseLocationUpdate || packet.Type == PacketType.AvatarGroupsReply) && allowSplitting)
allowSplitting = false;
try
{
if (allowSplitting && packet.HasVariableBlocks)
{
byte[][] datas = packet.ToBytesMultiple();
int packetCount = datas.Length;
if (packetCount < 1)
m_log.Error("[LLUDPSERVER]: Failed to split " + packet.Type + " with estimated length " + packet.Length);
for (int i = 0; i < packetCount; i++)
{
byte[] data = datas[i];
SendPacketData(agent, data, packet.Type, category);
}
}
else
{
byte[] data = packet.ToBytes();
SendPacketData(agent, data, packet.Type, category);
}
}
catch (NullReferenceException)
{
System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(1, true);
m_log.Error("An invalid " + packet.Type + " packet was built in:" + Environment.NewLine + trace.ToString());
}
}
示例15: Read
private void Read(string path, int sno, string engt_id, string ps_wkno)
{
Microsoft.Office.Interop.Excel.Application xlApp = null;
Excel.Workbook xlWorkbook = null;
Excel.Sheets xlSheets = null;
Excel.Worksheet xlNewSheet = null;
Excel.Worksheet xlscvsheet = null;
try
{
#region initial
xlApp = new Microsoft.Office.Interop.Excel.Application();
if (xlApp == null)
return;
xlWorkbook = xlApp.Workbooks.Open(path, 0, false, 5, "", "",
false, Excel.XlPlatform.xlWindows, "",
true, false, 0, true, false, false);
int boindex = 0, sumindex = 0, cvrindex = 0;
for (int l = 1; l <= xlWorkbook.Sheets.Count; l++)
{
if (xlWorkbook.Sheets[l].Name.ToString().Trim().Replace(" ", "").ToLower() == "boxoffice")
{
boindex = l;
}
if (xlWorkbook.Sheets[l].Name.ToString().Trim().Replace(" ", "").ToLower() == "coversheet")
{
cvrindex = l;
}
if (xlWorkbook.Sheets[l].Name.ToString().Trim().Replace(" ", "").ToLower() == "summary")
{
sumindex = l;
}
}
xlSheets = xlWorkbook.Sheets as Excel.Sheets;
xlNewSheet = (Excel.Worksheet)xlSheets[boindex];
xlNewSheet.Unprotect("7135");
Excel.Worksheet excelsheet3 = null;
excelsheet3 = (Excel.Worksheet)xlSheets[sumindex];
DataTable dt = new DataTable("table1");
DataTable dt1 = new DataTable("table2");
DataTable dtcvr = new DataTable("tablecvr");
DataTable dtchr = new DataTable("tablecvrchg");
string filename = xlNewSheet.Name;
#endregion
#region getrecordid
xlscvsheet = (Excel.Worksheet)xlSheets[cvrindex];
string shname = "", city = "", recid = engt_id;
DateTime opdate, endate;
shname = xlscvsheet.Cells[1, 1].Text;
city = xlscvsheet.Cells[3, 2].Text;
opdate = Convert.ToDateTime(xlscvsheet.Cells[8, 1].Text);
endate = Convert.ToDateTime(xlscvsheet.Cells[8, 2].Text);
xlNewSheet.Cells[sno, 14] = shname;
xlNewSheet.Cells[sno, 15] = city;
xlNewSheet.Cells[sno, 16] = opdate;
xlNewSheet.Cells[sno, 17] = endate;
MasterDataLayer.MasterData objmst = new MasterDataLayer.MasterData();
//DataTable dt_id = new DataTable();
//dt_id = objmst.GetMysql_Recordid(shname, city, opdate, endate);
//if (dt_id.Rows.Count > 0)
//{
// recid = dt_id.Rows[0]["RecordID"].ToString();
//}
//else { recid = "7604"; }
#endregion
#region engt dt creation
dt.Columns.Add("Sno");
dt.Columns.Add("Recordid");
dt.Columns.Add("Show Name");
dt.Columns.Add("City Name");
dt.Columns.Add("Engt_Date");
dt.Columns.Add("Deal_Tax_Ptg");
dt.Columns.Add("Deal_Tax2_Ptg");
dt.Columns.Add("deal_sub_sales_comm");
dt.Columns.Add("deal_ph_sales_comm");
dt.Columns.Add("deal_web_sales_comm");
dt.Columns.Add("deal_cc_sales_comm");
dt.Columns.Add("deal_remote_sales_comm");
dt.Columns.Add("deal_single_tix_comm");
dt.Columns.Add("deal_grp_sales_comm1");
dt.Columns.Add("deal_grp_sales_comm2");
dt.Columns.Add("deal_misc_othr_amt_1");
dt.Columns.Add("deal_misc_othr_amt_2");
dt.Columns.Add("deal_royalty_income");
dt.Columns.Add("deal_incm_wthd_tax_act_amt");
dt.Columns.Add("deal_guarantee_income");
dt.Columns.Add("deal_cmpny_mid_monies_ptg");
dt.Columns.Add("deal_producer_share_split_ptg");
dt.Columns.Add("deal_star_royalty_ptg");
dt.Columns.Add("deal_presenter_share_split_Ptg");
dt.Columns.Add("exp_d_ad_gross_bgt");
dt.Columns.Add("exp_d_ad_gross_act");
dt.Columns.Add("exp_d_stghand_loadin_bgt");
dt.Columns.Add("exp_d_stghand_loadin_act");
dt.Columns.Add("exp_d_stghand_loadout_bgt");
dt.Columns.Add("exp_d_stghand_loadout_act");
dt.Columns.Add("exp_d_stghand_running_bgt");
//.........这里部分代码省略.........