我使用的是Visual Studio 2010专业版和Windows Vista.
首先,我有这个代码.如你所见,它会使程序崩溃!
using System;
namespace Crash
{
class Program
{
static void Main(string[] args)
{
string a = null;
if (a.Length == 12)
{
// ^^ Crash
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
该程序将在if语句中崩溃.现在,我想知道它在if语句中崩溃了.
如果我从Visual Studio"开始没有调试",Crash.exe崩溃.它使用1,356kb的内存.我得到了Close Program/Debug的Vista选项.如果我选择Debug,我可以打开一个新的Visual Studio实例,它指向if语句的NullReferenceException.这很好.
现在让我假设它在另一台计算机上崩溃了,我让他们通过任务管理器给我一个转储文件.它是54,567kb.为什么这么大!这是巨大的!无论如何,我对此不太感兴趣(略)
如果我用Windbg打开那个转储,我对未经训练的眼睛几乎没有用处:
Microsoft (R) Windows Debugger Version 6.12.0002.633 X86
Copyright (c) Microsoft Corporation. All rights reserved.
Loading Dump File [C:\Users\Richard\Desktop\Crash.DMP]
User Mini Dump File with Full Memory: Only application data is available
Symbol search path is: SRV*C:\SYMBOLS*http://msdl.microsoft.com/download/symbols
Executable search path is: …Run Code Online (Sandbox Code Playgroud) 有谁知道如何获取字符串的枚举值?
例:
private static void PullReviews(string action, HttpContext context)
{
switch (action)
{
case ProductReviewType.Good.ToString():
PullGoodReviews(context);
break;
case ProductReviewType.Bad.ToString():
PullBadReviews(context);
break;
}
}
Run Code Online (Sandbox Code Playgroud)
编辑:
当试图使用ToString(); 编译器抱怨因为case语句期望一个常量.我也知道ToString()是用intellisense中的一行打出来的
使用此web.config元素设置会话状态超时
<sessionState mode="InProc" cookieless="false" timeout="120" />
Run Code Online (Sandbox Code Playgroud)
表单auth是使用此web.config元素配置的
<system.web>
<authentication mode="Forms">
<forms loginUrl="Login.aspx"
protection="All"
timeout="30"
name=".ASPXAUTH"
path="/"
requireSSL="false"
slidingExpiration="true"
defaultUrl="default.aspx"
cookieless="UseDeviceProfile"
enableCrossAppRedirects="false" />
</authentication>
</system.web>
Run Code Online (Sandbox Code Playgroud)
每个元素中指定的超时之间有什么区别?如果两者不同,它会如何工作?
我需要将CurrentCulture修复为ASP.NET应用程序中的不变文化.我怎样才能做到这一点?
<configuration>
<system.web>
<globalization culture="???" />
...
Run Code Online (Sandbox Code Playgroud) An int(Int32)的内存占用为4个字节.但是什么是内存占用:
int? i = null;
Run Code Online (Sandbox Code Playgroud)
并且:
int? i = 3;
Run Code Online (Sandbox Code Playgroud)
这是一般的还是类型依赖的?
在多语言网站中,我可以依靠javascript confirm来翻译Ok/Cancel按钮的文本吗?如果是,它是否与浏览器或OS语言设置有关?
解:
我也同时移动了ashx和asmx文件.WebService/WebHandler指令的Class属性指向错误的命名空间.故事的寓意是确保通过右键单击它们并选择"查看标记"来查看更改命名空间的所有 as*x文件的标记.
我遇到了与此问题和此链接相同的问题,但没有一个答案解决了我的问题.(编辑:设置web.config批处理属性有效,但这是一个掩盖,而不是解决方案)
我遇到的问题是用户控件,我从根目录移动到同一Web应用程序项目中的子目录.在移动它之前,它曾经很好地工作.当我移动它时,它开始给我错误信息.
它说类名存在于临时ASP.NET文件中的两个dll文件中.果然,当我打开Reflector时,它就在两个dll中.
如果我重命名类和ascx文件,一切正常.在我的整个应用程序的任何文件中都不存在原始名称的用法.当我重命名文件时,我打开了带有Reflector的Temporary ASP.NET Files中的所有dll文件,并且不存在对原始类名的引用.
那么这个幽灵参考来自何处我能解决这个问题?
更新:我实际上在工作目录中为解决方案和我的临时目录中的每个文件添加了旧类名,并删除了包含它的每个文件.然后我重命名回原来的,破碎的名字,我仍然得到错误.
'/'应用程序中的服务器错误.编译错误说明:在编译服务此请求所需的资源期间发生错误.请查看以下特定错误详细信息并相应地修改源代码.
编译器错误ssage:CS0433:类型'ASP.dashboard_badusercontrol_ascx'存在于'c:\ Docunts和Settings\me\Local Settings\Temp\Temporary ASP.NET Files\root\3c2b7e1f\2e8a7620\App_Web_badusercontrol.ascx.a57ad085.iljdmp1p .dll'和'c:\ Docunts and Settings\me\Local Settings\Temp\Temporary ASP.NET Files\root\3c2b7e1f\2e8a7620\App_Web_bhdqaimy.dll'
来源错误:
第1098行:第1099行:
[System.Diagnostics.DebuggerNonUserCodeAttribute()]第1100行:私有全局:: ASP.dashboard_badusercontrol_ascx @__ BuildControlMyBadUserControl(){第1101行:
global :: ASP.dashboard_badusercontrol_ascx @__ctrl; 1102行:源文件:c:\ Docunts and Settings\me\Local Settings\Temp\Temporary ASP.NET Files\root\3c2b7e1f\2e8a7620\App_Web_foo.aspx.a57ad085.1nw6dais.0.cs Line:1100
编辑:好的,所以我做了一些关于哪些有效和无效的测试.假设名称空间"MyNamespace"中的原始文件名是"BadUserControl.ascx".
我将文件移动到名为"NewDirectory"的目录,并将名称空间更改为"MyNamespace.NewDirectory".我的硬盘上没有"BadUserControl.ascx"的副本.我仔细检查了我的TFS历史记录,以确保唯一的区别是在标记和代码隐藏文件中添加".NewDirectory"到命名空间.
在这个命名空间内是另外两个名为"OtherUserControl"和"AnotherUserControl"的用户控件.
这种情况失败:我有2个Register指令:
<%@ Register src="BadUserControl.ascx" tagname="BadUserControl" tagprefix="uc1" %>
<%@ Register src="OtherUserControl.ascx" tagname="OtherUserControl" tagprefix="uc2" %>
Run Code Online (Sandbox Code Playgroud)
这些情况有效:
我保持命名为"BadUserControl.ascx".我在同一名称空间的页面上有1个Register指令:
<%@ Register src="BadUserControl.ascx" tagname="BadUserControl" tagprefix="uc1" %>
Run Code Online (Sandbox Code Playgroud)我将"BadUserControl.ascx"更改为"GoodUserControl.ascx"我有2个Register指令:
<%@ Register src="GoodUserControl.ascx" tagname="GoodUserControl" tagprefix="uc1" %> …Run Code Online (Sandbox Code Playgroud).NET字符串函数是否IndexOf("blah")区分大小写?
从我记得他们不是,但由于某种原因,我看到我的应用程序中的错误,查询字符串中的文本是在驼峰的情况下(如UserID),我正在测试IndexOf("userid").
在SignOut()调用之后使用此方法重定向到'... login.aspx?ReturnUrl =%2fmydomainname%2flogout.aspx',以便用户无法再次重新登录,因为成功登录将返回到注销页面.登录页面在webconfig中设置,应用程序成功获取该页面.为什么ReturnURL会卡在URL的尾部?
我有一个ASP.NET应用程序,它使用ASP.NET AJAX(包括UpdatePanel)和由不同背景的几个开发人员编写的jQuery.
一些包含ScriptManager本身内的脚本<asp:ScriptManager><Scripts><asp:ScriptReference....,而其他包含在Page.ClientScript.RegisterClientScriptInclude后面的代码中,而其他<script src="">脚本直接包含脚本.
如果可能的话,我想整合到一种处理这种方式,但我不确定每种方式的优缺点是什么,哪种方式更受欢迎.
一个例子是:
protected override void Render(HtmlTextWriter writer)
{
Page.ClientScript.RegisterClientScriptInclude("jQuery", ResolveClientUrl("~/scripts/jquery/js/jquery-1.4.2.min.js"));
base.Render(writer);
}
Run Code Online (Sandbox Code Playgroud)
VS
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Path="~/scripts/jquery/js/jquery-1.4.2.min.js" />
</Scripts>
</asp:ScriptManager>
Run Code Online (Sandbox Code Playgroud)
VS
<script src="Scripts/jQuery/js/jquery-1.4.2.min.js" type="text/javascript"></script>
Run Code Online (Sandbox Code Playgroud) c# ×5
asp.net ×4
.net ×2
javascript ×2
.net-3.5 ×1
confirm ×1
crash-dumps ×1
debugging ×1
localization ×1
memory ×1
nullable ×1
web-config ×1