随笔分类 - 捉虫记
摘要:BackgroundIn our application, we have a screen which hosts several tabs. In each tab, it contains a third-party GridControl (like the WPF standard GridView control). And we need to display some column cells as hyper link, so user can click on it, view more details. So we have customized the Cell tem
阅读全文
摘要:记录一段小经历,当我们嗅觉到一段有问题的代码时,仔细研究下会有不错的发现。经验总结:当我们跟IntPtr打交道时一定要小心谨慎,谨防GDI泄漏Yesterday, I noticed that someimage resources in Annotation project are not defined as static, the clientdirectly access by ̶...
阅读全文
摘要:相信大部分熟读过《CLR Via C#》一书的人应该明白文字代码问题出在哪里,因为道理都在那本书里摆着。
至于我为什么写此文重谈一遍,一个是因为读书归读书,碰到实际情况时就不见得也能保持冷静明白个所以然,能够避免踩此陷阱; 二则我也很难理解我们的架构师为什么会犯此错误,是故意的呢还是不够仔细踩了地雷。
于是写此文记录一下,以免今后自己犯此错误。各位有则改之,无则加勉
阅读全文
摘要:以下代码源自于真实项目,本人只是做了一点简化,大家来找碴,看看哪些地方不妥:-)
阅读全文
摘要:I have create a HwndSource who will host a WPF TextBox control and set it on topmost, then popup it when user double clicks on the node. Please refer to the following code: Code highlighting produc...
阅读全文
摘要:GDI泄露这玩意儿以前压根没听过, 第一次了解到这东西存在是在很久很久以前在我们的项目中真实遇到过了,当时的情况是这样的一同事发现狂点菜单某一选项几分钟,程序就会crash,而且每次都能重现,起初猜测是资源泄露,后来打开任务管理器监视GDI Object一栏发现每点一次菜单,GDI Object的数量就飙涨,差不多到10000的时候程序就会crash。当时很佩服那同事咋能发现那Bug,也惊奇任务管理器竟然能监视那么多的资源利用。
最后发现栽在于创建Bitmap却忘记释放,好像跟Handler有关
阅读全文
摘要:不能正常捕捉异常,应用程序有任何未处理的异常,就直接crash,抛出系统错误框
阅读全文
摘要:昨天同事跟我说尽量少用try{}catch(),因为比较耗性能, 对于值类型的转型可以用Nullable类型转然后判空, 如: float? size = value as float?; if (size.HasValue) ... 改写后发现原来的功能不工作了,,size始终得不到值,,跟踪后发现value必须为float型才能转型成功。 然而自己平时都是习惯于不显示声明数值...
阅读全文
摘要:Debug时莫名的抛出异常,莫名的无助啊。 幸亏Google得到, 最终的解决方法是 在Debug -> Exceptions -> Managed Debug Assistants里 去掉ContextSwitchDeadlock一项前面的钩 详细可见ContextSwitchDeadlock was detected when debugging in Visual Studio 2005 ...
阅读全文
摘要:最近同事遇到一个问题,关于程序需要在动态的时候决定究竟要加载dll的哪个版本.
制造事故,利用AssemblyResolve事件完美解决之!
阅读全文
摘要:今天在编译项目的时候出现了如下错误 The command "cscript E:\Schemas\UpdateSchemaClass.js "C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\..\..\SDK\v2.0\Bin\xsd.exe" " exited with code 1.PackageSchemas 看了下大致的...
阅读全文
摘要:1. Click on Start and Run and type in the exact string as below in one single line: reg.exe DELETE HKEY_CURRENT_USER\Software\Microsoft\MSNMessenger\Policies /va2. Hit Enter. 3. Press on "Y" to confir...
阅读全文