- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
这是一个面试问题,我需要帮助。
您有以下 ASP.NET 代码隐藏类:
public partial class Page1 : Page
{
private string _value;
public Page1()
{
if (DateTime.Now.Ticks % 10 == 0)
_value = "Test";
}
~Page1()
{
if(_value.Equals("Test"))
_value = string.Empty;
}
}
只要有人请求此页面,w3wp.exe
进程就会意外终止。
为什么会发生这种情况,而用户看到的是死机蓝屏(默认 ASP.NET 错误页面)?
为什么托管堆上总是出现 OutOfMemoryException?
最佳答案
提示:永远不要在析构函数/终结器中抛出异常,否则您将终止运行 GC 的线程,如果没有 GC,事情可能会变得很糟糕。
虽然 .NET 1.1 对在后台线程中抛出的异常有一定的容忍度,这些异常已被消耗并且不会导致托管进程停止,但从 CLR 2.0 开始就不再如此了。 Quote from the doc :
If Finalize or an override of Finalize throws an exception, and the runtime is not hosted by an application that overrides the default policy, the runtime terminates the process and no active try-finally blocks or finalizers are executed. This behavior ensures process integrity if the finalizer cannot free or destroy resources.
在终结器中抛出异常是致命的。
关于C#面试题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5598334/
总览 数据库的数据存储有两种类型,一种是面向行的(row-oriented)数据库,另一种是面向列的(column-oriented )数据库。 面向行(事务型) 数据库 该类数据库是根据
starting from a joke 问:把大象放冰箱里,分几步? 答:三步啊,第1、把冰箱门打开,第2、把大象放进去,第3、把冰箱门带上。 问:实现spring事务,分几步? 答:三
在最近的一次采访中,我有这个问题。 这里有什么错误?我知道足够的 c#,但我看不到错误。可以吗? Class x { protected string t1; public int
我在面试中被要求设计一个文件系统,允许用户将自己的属性添加到文件和文件夹中。我刚刚说过要将属性添加到文件描述符并允许根据此属性标准搜索文件,以及添加此属性以显示在文件/文件夹详细信息中。 看起来面试官
我一直在面试,下面应该有什么问题? 我可以假设这是您无法检查类是否为空的问题,对吗?!谢谢! public class NiceActivity extends Activity { priv
给定一个数组,如何返回总和为偶数的对数? 例如: a[] = { 2 , -6 , 1, 3, 5 } 在这个数组中,偶数和的对数是(2,-6), (1,3) , (1,5), (3,5) 函数应返回
这个问题是在面试中被问到的 Assume you have a dictionary of words: (use if you have /usr/share/dict/words). Given
我被要求实现 invert(x,p,n) 返回 x 的 n 位开始于位置 p 反转(即 1 变为 0,反之亦然),其他不变。 我的解决方案是: unsigned invert(unsigned x,
有人问我这个问题:给定一个大小为 n 的 int 和 int sum 的数组,我需要返回数组元素的所有对,其总和等于 总和 std::vector > find(int* arr,size_t n,i
我在一次面试中遇到了这个问题。有一组对象与起始值和结束值相关联。与每个对象相关联的计数是具有较长开始时间和较短结束时间的其他对象的数量。所以我必须找到与每个对象关联的计数。 我提出了 O(n^2) 解
我今天在采访中被问到这个问题。我已经尝试了一种解决方案,但想知道是否有更好的方法来解决这个问题: 问题:我有一个包含 500,000 个元素的数组列表,这样数组列表的每个元素的值都与索引相同。例如:l
有一个包含白色单元格,黑色单元格和只有一个灰色单元格的矩阵,需要从 (0,0) 到 (N-1, N-1) 如果 Arra[N][N]约束:A。该路径应该只覆盖白色单元格并且应该通过灰色单元格。b.访问
给定一个正整数数组,找出排列的任意排列可以形成的最大值。我想知道是否有更好的数据结构可以为问题提供更优雅的解决方案。 import java.util.ArrayList; import java.u
我在面试中被问到以下问题(不幸的是我找不到比 N^2 更好的答案) 对于大小为 N 的 unsigned int 的给定数组 arr,对于每个元素(在索引 i 中)我应该返回一个元素在索引 j (j
极点:数组中左侧元素小于或等于它且右侧元素大于或等于它的元素。 示例输入 3,1,4,5,9,7,6,11 期望的输出 4,5,11 面试时被问到这个问题,要返回元素的索引,只返回第一个满足条件的元素
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我今天被问到这个问题,我知道答案很简单,但他让我一直到最后。 问题 编写程序删除存储在 ArrayList 中的偶数,其中包含 1 - 100。 我只是说哇 给你,这就是我的实现方式。 ArrayLi
我在一次采访中遇到了这个问题,完全被难住了。我能想到的唯一解决方案是将 currentAngle 存储在 NSArray 中以计算下一个角度。 问题:使用 iPhone 的指南针在屏幕上移动一个 35
我必须在接下来的几周内采访一些 C++ 候选人,作为公司最资深的程序员,我应该尝试弄清楚这些人是否知道他们在做什么。 那么有人有什么建议吗? 就我个人而言,我讨厌被留在房间里填写一些 C++ 问题,所
消息队列(MQ),一种能实现生产者到消费者单向通信的通信模型,这也是现在常用的主流中间件。 常见有 RabbitMQ、ActiveMQ、Kafka等 他们的特点也有很多 比如 解偶、异步、广播
我是一名优秀的程序员,十分优秀!