我正在处理出现此错误的 c# 应用程序。
这是错误的堆栈跟踪:
堆栈跟踪:在 System.Guid.TryParseGuid(String g, GuidStyles flags, GuidResult& result) 在 System.Guid..ctor 的 System.Guid.GuidResult.SetFailure(ParseFailureKind failure, String failureMessageID, Object failureMessageFormatArgument, String failureArgumentName, Exception innerException) (String g) at Projects_AddProject.wizCreateProject_ActiveStepChanged(Object sender, EventArgs e) at System.Web.UI.WebControls.Wizard.OnActiveStepChanged(Object source, EventArgs e) at System.Web.UI.WebControls.Wizard.MultiViewActiveViewChanged(Object source, EventArgs e) 在 System.Web.UI.WebControls.MultiView.OnActiveViewChanged(EventArgs e) 在 System.Web.UI.WebControls.MultiView.set_ActiveViewIndex(Int32 值) 在 System.Web.UI.WebControls.Wizard.set_ActiveStepIndex(Int32 值) 在 Projects_AddProject。在 System.Web.UI.ScriptManager.LoadHistoryState(String serverState) 在 System.Web.UI.ScriptManager.RaiseNavigate(HistoryEventArgs e) 在 System.Web.UI.ScriptManager.RaisePostBackEvent(String eventArgument) 的 proxy_Navigate(Object sender, HistoryEventArgs e)在 System.Web.UI.ScriptManager.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(字符串 eventArgument)
从将字符串转换为guid时发生的错误。发生这种情况的方法是 wizCreateProject_ActiveStepChanged。它看起来是一些 Guid 转换问题。
这是产生错误的方法:
protected void wizCreateProject_ActiveStepChanged(object sender, EventArgs e)
{
switch (wizCreateProject.ActiveStepIndex)
{
case 0:
if (rbFrmTemp.Checked)
{
int tenantID = TenantUtils.getTenantId(Page);
EzProject templateProject = DBAccessProjects.GetProject(tenantID, new Guid(ddlProjTemplates.SelectedValue));
txNme.Text = templateProject.ProjectName;
txDesc.Text = templateProject.ProjectDescription;
CheckLoadWorkType(tenantID, ddlWrkType);
if (templateProject.WorkTypeID != null)
{
ListItem workItem = ddlWrkType.Items.FindByValue(templateProject.WorkTypeID.ToString());
if (workItem != null)
{
ddlWrkType.SelectedValue = templateProject.WorkTypeID.ToString();
}
}
if (templateProject.ProjectType == (int)ProjectType.Reoccurring)
{
CheckGroupedRadioButton(rbReoccurring);
txBilFreq.Text = templateProject.BillingFrequency.ToString();
if (templateProject.LastDate != null)
{
txtDate.Text = ((DateTime)templateProject.LastDate).ToShortDateString();
}
ListItem prdItem = ddlBilPrd.Items.FindByValue(templateProject.BillingPeriod);
if (prdItem != null)
{
ddlBilPrd.SelectedValue = prdItem.Value;
}
ScriptManager.RegisterClientScriptBlock(upPnlProject, typeof(UpdatePanel), upPnlProject.ClientID, "TypeChanged();", true);
wizCreateProject.ActiveStepIndex = 2;
}
else
{
wizCreateProject.ActiveStepIndex = 3;
}
BtnADD.Visible = true;
}
else
{
if (rbReoccurring.Checked)
{
ScriptManager.RegisterClientScriptBlock(upPnlProject, typeof(UpdatePanel), upPnlProject.ClientID, "TypeChanged();", true);
}
}
break;
case 3:
txNme.Focus();
ScriptManager.RegisterClientScriptBlock(upPnlProject, typeof(UpdatePanel), upPnlProject.ClientID, "InitNames();", true);
break;
default:
break;
}
}