分类: C#|DOTNET
发布: yaosansi
浏览:
日期: 2010年7月20日
I will talk today about a very common issue we face when we try to use .NET's RSACryptoServiceProvider class in ASP.NET.When we try to create a new RSACryptoServiceProvider object in this scenario, we may get the following exception: "System.Security.Cryptography.CryptographicException: The system cannot find the file specified".By using my CryptoAPI Tracer script we can take a look to the CryptoAPI calls that .NET is making behind the scenes. Thanks to this script we will be able to see the exact API that is failing and the exact error (which most of the time .NET masks).In our case, the API that fails is CryptAcquireContext, and it fails with error #2 (ERROR_FILE_NOT_FOUND). According to CryptAcquireContext documentation, this error means the following:"The profile of the user is not loaded and cannot be found. This happens when the application impersonates a user, for example, the IUSR_ComputerName account."By default, ASP.NET won't load the user profile. Take a look to the parameters of the problematic CryptAcquireContext call as being shown in the log file that my script generated. If this API is not being called with CRYPT_MACHINE_KEYSET (to use the machine profile) or CRYPT_VERIFYCONTEXT (to use temporary key stores), it will try to access the key stores in the user profile, and it will fail because its not loaded.
分类: C#|DOTNET
发布: yaosansi
浏览:
日期: 2010年6月17日
在 .NET Framework 3.5 beta 时,微软曾引入了一个新的包 System.Numerics,其中包含了大整数(BigInteger)类,不过可惜在后来的接近发布时,这个包又移除了。现在 .NET Framework 4.0 又重新将它请了回来。而且这次的正式版本中不会再次移除了。这对 .NET 开发者算是一个好事,但如果只有使用 .NET Framework 4.0 的用户才能享受到这个包,还是不太完美,毕竟现在大多数 .NET 开发还停留在 2.0 或 3.5 的阶段。
分类: C#|DOTNET
发布: yaosansi
浏览:
日期: 2010年6月16日
Introduction to Second VersionThis is a new, extended, improved version of my original article. This was (and is) my first (and only until now) CodeProject article. It was well rated, but at the same time a lot of people suggested corrections, alternatives and improvements. So I will use all this new info to show you a better way to do the same thing. Every improvement in my code was suggested by someone else, so this is some sort of collective writing. I'm just compiling things that you can read in the forum. But since I don't always read the forum, it makes sense to me to make some "text oriented maintenance". I will try to give everyone his own credit.There are two solutions now inside the download, one for VS2008 with four projects (Desktop and Compact Framework for C# 3.5 and C# 2.0) and another one for VS2005 with four projects (Desktop and Compact Framework for C# 2.0, two different ways to solve the problem for each).At the very end of the article, you will find what I think now is the "official" way (the Microsoft way) to solve this problem. I didn't know about this method until a couple of people post about it in the forum. At least, read that (click here). But I will stick to my way of solving this issue. The following text is pretty much the exact text from the original article; new text begins below the second horizontal line. Enjoy.
分类: C#|DOTNET
发布: yaosansi
浏览:
日期: 2010年5月28日
Function evaluation disabled because a previous function evaluation timed out. You must continue execution to reenable function evaluationIf you ever try to debug a multi-threaded Windows Forms application, today's blog is for you. A customer asked me about this issue, and since I have also run into this problem, I decided to talk about it. What is func eval?If you already know what func eval is, or don't care, skip to the bottom.For the rest of us, I wanted to give some background. Func Eval is short for 'function evaluation'. The idea is this: instead of just reading data out of the debuggee process to fill out the watch window, the debugger actually causes code to run inside the debuggee process. It does this by hijacking the stopped thread, and running something entirely different on that thread. Func eval has been a feature of the Visual Studio debugger for a while now.
分类: C#|DOTNET
发布: yaosansi
浏览:
日期: 2010年5月28日
随着网站访问量的增加,很多大流量网站都使用了LazyLoad延迟加载技术,特别是图片较多的网站,如:淘宝、土豆等。 在包含很多大图片长页面中延迟加载图片可以加快页面加载速度. 浏览器将会在加载可见图片之后即进入就绪状态. 在某些情况下还可以帮助降低服务器负担.
分类: C#|DOTNET
发布: yaosansi
浏览:
日期: 2010年5月26日
Win32应用程序主要有两种类型:控制台应用程序(Console)和窗体程序(Winform),他们使用不同的方式处理应用程序退出。要强制窗体程序(Winform)退出,你需要发送WM_CLOSE消息到主窗口句柄。.NET中可以使用Application.ApplicationExit或Form.Close。在控制台应用程序,这点有所不同。控制台应用程序有点模仿DOS控制台应用程序,通常是在应用程序退出时,进程(命令)执行结束或Ctrl - C被按下。
分类: C#|DOTNET
发布: yaosansi
浏览:
日期: 2010年4月29日
项目需要动态生成一些类,现总结以下几种方式:1.永春博客里提供的将string动态编译类的方式2.使用Emit动态创建类,并添加实例成员,属性,方法等
分类: C#|DOTNET
发布: yaosansi
浏览:
日期: 2010年4月29日
应用程序体系结构在我专攻代码之前,我想谈谈我尝试做的事。您可能记得,SuperGraph 让您从函数列表中进行选择。我希望能够在具体的目录中放置外接程序程序集,让 SuperGraph 检测它们,加载它们,并找到它们中包含的所有函数。如果 SuperGraph 自己能完成此操作则不需要单独的 AppDomain。Assembly.Load() 通常运行良好,但程序集无法独立卸载(只有 AppDomain 可以卸载)。这意味着如果您正在编写服务器,而且您希望用户无需启动和停止服务器即能更新他们的外接程序,那么您将无法使用默认的 AppDomain 实现此任务。要实现此功能,我们将在一个独立的 AppDomain 中加载所有外接程序程序集。当添加或修改文件时,我们将卸载 AppDomain,创建新的 AppDomain,然后将当前文件加载到其中。这样,一切就都完美无缺了。
分类: C#|DOTNET
发布: yaosansi
浏览:
日期: 2010年4月29日
在C++中加载和卸载DLL是一件很容易的事,LoadLibrary和FreeLibrary让你能够轻易的在程序中加载DLL,然后在任何地方卸载。在C#中我们也能使用Assembly.LoadFile实现动态加载DLL,但是当你试图卸载时,你会很惊讶的发现Assembly没有提供任何卸载的方法。这是由于托管代码的自动垃圾回收机制会做这件事情,所以C#不提供释放资源的函数,一切由垃圾回收来做。
分类: C#|DOTNET
发布: yaosansi
浏览:
日期: 2010年4月22日
分类: C#|DOTNET
发布: yaosansi
浏览:
日期: 2009年8月1日
7-Zip 是一款号称有着现今最高压缩比的压缩软件,它不仅支持独有的 7z 文件格式,而且还支持各种其它压缩文件格式,其中包括 ZIP, RAR, CAB, GZIP, BZIP2和 TAR 等等。此软件压缩的压缩比要比普通 ZIP 文件高 30-50% ,因此,它可以把 Zip 格式的文件再压缩 2-10% 。 7-Zip 主要特征 更新了算法来加大 7z 格式 的压缩比 支持格式: 压缩及解压缩:7z、ZIP、GZIP、BZIP2 和 TAR 仅解压缩:RAR、CAB、ISO、ARJ、LZH、CHM、WIM、Z、CPIO、RPM、DEB 和 NSIS 对于 ZIP 及 GZIP 格式,7-Zip 能提供比使用 PKZip 及 WinZip 高 2-10% 的压缩比 7z 格式支持创建自释放(SFX)压缩档案 集成 Windows 外壳扩展 强大的的文件管理 强大的命令行版本 支持 FAR Manager 插件 支持 69 种语言
分类: C#|DOTNET
发布: yaosansi
浏览:
日期: 2009年3月5日
IKVM.NET是一个针对Mono和微软.net框架的java实现,其设计目的是在.NET平台上运行java程序。它包含了以下的组建:* 一个用.NET实现的java虚拟机 * 一个java类库的.NET实现 * 致力于在java和.NET之间交互的工具