随笔分类 - .NET&C#
摘要:今天试了下强命名是不是能够防止Dll被篡改,按照原理,如果你更改了Dll,CLR在load Dll的时候,验证是不能通过的,Dll是不会被load的。 可是实际情况not the case! 当你用Binary Editor更改了Dll, 例如改变了字符串某个字符,Dll会被load 弄了半天,原来才发现是强命名验证被.NET优化了 http://msdn.microsoft.com/zh-cn/...
阅读全文
摘要:转贴:http://www.ruanyifeng.com/blog/2011/08/what_is_a_digital_signature.html 原帖:http://www.youdzone.com/signature.html 1. 鲍勃有两把钥匙,一把是公钥,另一把是私钥。 2. 鲍勃把公钥送给他的朋友们----帕蒂、道格、苏珊----每人一把。 3. 苏珊要给鲍勃写一封保密的信。她写完后...
阅读全文
摘要:.NET Remoting也是基于消息的远程调用
阅读全文
摘要:COM .NET Interoperability, Runtime Callable Wrapper (RCW), COM Callable Wrapper (CCW).
阅读全文
摘要:Error: Constant value '2147483648' cannot be converted to a 'int' (use 'unchecked' syntax to override) Reason: 计算机在内部用的是补码, 所以: byte类型的范围:(负数最小值,1既是符号位又是值位) Dec: &...
阅读全文
摘要:如下代码示例如何在C#中取得Win32的GetLastError. // this function is just for fun [DllImport("winusb.dll", SetLastError = true)] public static extern bool WinUsb_SetPowerPolicy(IntPtr InterfaceHandle, UInt32 Policy...
阅读全文
摘要:The WMI technique is very powerful for system related activities. They provide operating system interface. The following code can be used to close instance of visual studio on remote machine provided ...
阅读全文
摘要:If your XML file has xmlns, you may be run into problem when get some XML data with LINQ. How to fix this? 1. prepend the namespace XNamespace ns = doc.Root.Name.Namespace; var cars2 = from d in doc...
阅读全文
摘要:Reference: 正则表达式三十分钟入门: http://deerchao.net/tutorials/regex/regex.htm 在线测试工具: regexlib(http://regexlib.com/default.aspx) 吐血推荐,比较狠的一个工具: ...
阅读全文
摘要:MPF bug: creating the custom ProjectConfig classOld design: MPF ConfigProvider.cs:namespace Microsoft.VisualStudio.Package{public class ConfigProvider : IVsCfgProvider2, IVsProjectCfgProvider, IVsExte...
阅读全文
摘要:非托管与托管类型对比IntPtr表示指针或句柄的平台特定类型,使用WINDOW API时使用。就是void* 就是HANDLE, 具体如下表:Wtypes.h中的非托管类型 非托管C 语言类型 托管类名 说明 HANDLE void* System.IntPtr 32 位 BYTE unsigned char System.Byte 8 位 SHORT short System.I...
阅读全文
摘要:1. Install “HTML Help Workshop” from http://msdn.microsoft.com/en-us/library/ms669985(VS.85).aspxIf you have VS + VSSDK, no need to do this, because “HTML Help Workshop” is inc...
阅读全文
摘要:[代码]Int32 a, Int32 b;Swap<Int>(a,b)或者Float a, Float b; Swap<Float>(a, b)甚至Swap(a,b)编译器完成自动推断参数类型.这个就是C#泛型的小例子, 反映了泛型的第一个好处 "代码复用"。泛型,是在C++就已经有的事物了。我们知道C#是从2.0才开始支持的。泛型的好处就是代码复用,效率更高,类型安全。泛...
阅读全文
摘要:To create a new category and set of performance counters programmatically:代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--//CreateacollectionoftypeC...
阅读全文
摘要:使用ClickOnce过程中遇到了一个难题,App.config不能publish出去,在clickonce的application file列表里没有这个文件,因为我在app.config里面放了很多配置,所以程序加载失败。查找了一圈下来,尝试了多种,例如:如何:在 ClickOnce 应用程序中包括数据文件http://msdn.microsoft.com/zh-cn/library/6feh...
阅读全文
摘要:1. why "[STAThread]"?不知道你注意到没,WinForm程序一般都在main函数上有个特性[STAThread], 这是为什么呢?先从Apartments(单元)说起,我们知道WinForm程序需要调用很多传统win32的代码,所以要适应传统的单元模式。单元其实是包含线程和对象的容器。一个单元内的对象只能被这个单元内的线程调用。外部单元如何调用的?例如外部如何改变UI?需要Mar...
阅读全文
摘要:1. SynchronizationSimple Blocking MethodsConstructPurposeSleepBlocks for a given time period.JoinWaits for another thread to finish.Locking ConstructsConstructPurposeCross-Process?SpeedlockEnsures jus...
阅读全文
摘要:1. Overview进程是可执行单元,进程由线程组成。进程之间彼此独立,线程共用进程的堆内存,线程有独立的栈内存。现有的系统一般是多进程,多线程的。a. How threading works?线程由thread scheduler来管理,由系统分成time-slicing快速轮转执行(rapidly switching execution between each of the active ...
阅读全文


浙公网安备 33010602011771号