海鸥航迹

学习之笔记,好文之收集。

2008年4月9日 #

Ankh菜单删除

     摘要: 今天下载了AnkhSVN 试用来一番。它是一个Visual Studio IDE的一个插件,感觉仍然不如VSS或者Visual SVN方便,Unintall后,居然发现VS2005菜单上,仍然有AnkhSVN的菜单项目。要删除它...  阅读全文

posted @ 2008-04-09 22:01 海天一鸥 阅读(1689) | 评论 (7)编辑

2008年3月14日 #

VC8应用程序的发布问题

1. 问题描述:
最近在VS2005下用C++写了一个Console程序,在一台未安装VS2005的机器上不能正常运行。
用命令行方式运行,提示:
“系统无法执行指定的程序”
直接双击运行,提示:
“由于应用程序的配置不正确,应用程序未能启动,重新安装应用程序可能会纠正这个问题”
用VC6和VS2003也有这个问题,只不过会提示说找不到“***.dll”,把需要的dll拷贝到目标机器就可以正常运行了。而VS2005并没有提示缺少哪些dll。
2. 解决方案:
在水木C++版请教了一下,ass做出了回答(非常感谢ass的帮助)。把他的回答摘录如下,大家共同学习:
“因为没有msvcr80.dll
可以改一下编译选项 多线程dll(/MD)改成多线程(MT)这样就静态链接,
也可以从你的vc8安装盘上找到再分发包vcredist_xxx.exe和你的程序捆绑安装。”

也可到这里下载:

http://www.microsoft.com/downloads/details.aspx?familyid=200B2FD9-AE1A-4A14-984D-389C36F85647&displaylang=zh-cn


根据ass指导的思路,自己实验了一下,感觉以下两种解决办法是比较方便的:
方法一:
在C:Program FilesMicrosoft Visual Studio 8VCredi
stDebug_NonRedistx86Microsoft.VC80.DebugCRT 下找到了下列文件:
msvcm80d.dll
msvcp80d.dll
msvcr80d.dll
Microsoft.VC80.DebugCRT.manifest
把这几个文件拷贝到目标机器上,与运行程序同一文件夹或放到system32下,就可以运行那个程序了。

方法二:
修改“C++/Code Generation”中的运行时库选项,将/MD或/MDd 改为 /MT或/MTd,这样就实现了对VC运行时库的静态链接,在运行时就不再需要VC的dll了。

 

还有几个要注意的地方:在实际应用中,一个应用程序往往由DLL和EXE构成,若exe配置为MTd,则要解决上面的问题,DLL也必须是MTd。

posted @ 2008-03-14 21:07 海天一鸥 阅读(152) | 评论 (1)编辑

2008年3月13日 #

Session_end事件


Session End事件仅在进程内会话模式情况下,请求结束时,Session.Abandon()被调用时会被激发,或者会话过期时被激发。浏览器关闭并不会激发Session END事件。


Introduction

Sessions are maintained on the server. Sessions are created when a request is made by the client to the page. In this article we will look that when the Session_End event is fired.

When Session_End is fired:

Session End event is fired only in the In-Proc Session mode at the end of the request in which Session.Abandon() is called OR when the Session time expires. Session End will not be fired when you close the browser. Let's make a small test in the Global.asax file so that we will know that Session.Abandon is being called.

// Here we will clear the user from the List of logged users

public static string message = String.Empty;

protected void Session_End(Object sender, EventArgs e)

{

if(Session[Global.USERNAME] == null)

{

message = null;

message = "Session End has been fired";

}

}

Now say you press a button and call Session.Abandon() method which in turns fires the Session End event.

private void Button1_Click(object sender, System.EventArgs e)

{

Session.Abandon();

Label1.Text = Global.message;

}

If you run this page you will not see any text assigned to the Label control. Even though you did assign the text in the Session End event. Well, the text is assigned alright but you need to refresh the page in order to view it since it was not included in the request which you made. When you refresh the page you will see a message "Session End has been fired".

If you want to clean the Session Variable without destroying the Session than you can use the Session.Clear() method.

In the beginning of the article I said "Session End event is fired at the end of the request in which Session.Abandon() is called". We can do a simple test to prove this. If Session_End is fired instantly when Session.Abandon is executed than the following code should kill the Session and "Session Variable has been cleared" OR an error has to be raised since that Session has been destroyed. But if you run this code it will print "Session Variable is NOT Cleared". It's a good idea if you debug it and you will see that the Session End is fired at the end of the request and not instantly when it meets Session.Abandon

Session[Global.USERNAME] = txtUserName.Text;

// Clear the Current Session

Session.Abandon();

Label1.Text = Global.message;

if(Session[Global.USERNAME] == null)

{

Label1.Text = "Session Variable has been cleared";

}

else

{

Label1.Text = "Session Variable is NOT Cleared";

}

Firing an event when the browser closes:

YOU CANNOT CLEAR SESSION WHEN THE BROWSER CLOSES. You can fire client side event when the browser closes and hence you can do client tasks. In the code below when the user closes the window I am popping up an alert message. The message will also pop whenever any activity occurs on the page. It can be button click, refresh or any other activity.

<body onbeforeunload= 'PopWindow();' >

</body>
</HTML>
<script language ="javascript">
function PopWindow()
{
alert('You are about to close the window');
}
</script>

I hope you liked the article, happy coding!

posted @ 2008-03-13 19:33 海天一鸥 阅读(100) | 评论 (0)编辑

2008年3月6日 #

北京和家宾馆——一个不错的经济型酒店

经济型客房(138-198)

免费宽带,早餐免费;中晚餐自助 10元/位

北四环店: 010-82629013,9048 总机:010-82629195

地址:北京市海淀区成府路华清嘉园22号楼 房价:198元/间

安贞店:010-51697189 总机:010-51697188   138元/间

北京市朝阳区安外外馆斜街1号;(泰利明苑小区内150米)

百万庄店:010-68331987,总机:010-52605118  168元/间

地址:北京西城区百万庄大街23号(展览馆派出所东侧外交学院北门对面)

hejia

华谊店(华谊宾馆):010-62259611,总机:62259366  188元/间

地址:北京市海淀区索家坟20号

西直门桥向北学院路第一出口向东300米,向北200米同一首歌北侧;

白云路店:010-68046846,总机:68046848 168元/间

地址:北京市西城区真武庙3里8号桃兆园宾馆白云路4号国二招(长安商场向南300米第一个红绿灯东侧)

白云观一店(兆园宾馆):010-63423621,总机:63439503  168元/间

地址:北京市西城区白云观街8号院2号楼(白云观南门对面)

白云观二店:010-52603939 总机:52603636  168元/间

地址:北京市西城区白云观街8号院6号楼

白云桥店:010-51933225,总机:51933282  168元/间

地址:北京市宣武区白云桥西南50米

渤海府宾馆:0431-85089092       138元/间

地址:长春市新发路518号(吉林省委对面)

posted @ 2008-03-06 19:28 海天一鸥 阅读(857) | 评论 (0)编辑

2008年2月19日 #

SQLite.NET提供程序的选择

今日用到了SQLite,发现这个数据库进行了很大的升级,从3.4.X升级到3.5.X了。版本号发生改变,API接口OS层发生重大改变。

SQLite version 3.5.0 introduces a new OS interface layer that is incompatible with all prior versions of SQLite. In addition, a few existing interfaces have been generalized to work across all database connections within a process rather than just all connections within a thread. The purpose of this article is to describe the changes to 3.5.0 in detail so that users of prior versions of SQLite can judge what, if any, effort will be required to upgrade to newer versions.

1.0 Overview Of Changes

A quick enumeration of the changes in SQLite version 3.5.0 is provide here. Subsequent sections will describe these changes in more detail.

  1. The OS interface layer has been completely reworked:
    1. The undocumented sqlite3_os_switch() interface has been removed.
    2. The SQLITE_ENABLE_REDEF_IO compile-time flag no longer functions. I/O procedures are now always redefinable.
    3. Three new objects are defined for specifying I/O procedures: sqlite3_vfs, sqlite3_file, and sqlite3_io_methods.
    4. Three new interfaces are used to create alternative OS interfaces: sqlite3_vfs_register(), sqlite3_vfs_unregister(), and sqlite3_vfs_find().
    5. A new interface has been added to provided additional control over the creation of new database connections: sqlite3_open_v2(). The legacy interfaces of sqlite3_open() and sqlite3_open16() continue to be fully supported.
  2. The optional shared cache and memory management features that were introduced in version 3.3.0 can now be used across multiple threads within the same process. Formerly, these extensions only applied to database connections operating within a single thread.
    1. The sqlite3_enable_shared_cache() interface now applies to all threads within a process, not to just the one thread in which it was run.
    2. The sqlite3_soft_heap_limit() interface now applies to all threads within a process, not to just the one thread in which it was run.
    3. The sqlite3_release_memory() interface will now attempt to reduce the memory usages across all database connections in all threads, not just connections in the thread where the interface is called.
    4. The sqlite3_thread_cleanup() interface has become a no-op.
  3. Restrictions on the use of the same database connection by multiple threads have been dropped. It is now safe for multiple threads to use the same database connection at the same time.
  4. There is now a compile-time option that allows an application to define alternative malloc()/free() implementations without having to modify any core SQLite code.
  5. There is now a compile-time option that allows an application to define alternative mutex implementations without having to modify any core SQLite code.

Of these changes, only 1a and 2a through 2c are incompatibilities in any formal sense. But users who have previously made custom modifications to the SQLite source (for example to add a custom OS layer for embedded hardware) might find that these changes have a larger impact. On the other hand, an important goal of these changes is to make it much easier to customize SQLite for use on different operating systems.

 

由于存储层的改变,SQLite.NET的各个版本也发生了变化:

SQLite.NET 1.0.46是最后一个基于3.4.X版本的提供程序;
SQLite.NET 1.0.48是当前最新的基于3.5.4代码的提供程序;

SQLite.NET的新版本主要是随SQLite3.4->3.5的改进而进行了相应的修改。性能有很大变化,对比如下:

1.0.46 test

Beginning Test on System.Data.SQLite.SQLiteConnection
SUCCESS - CreateTable
SUCCESS - Full Text Search
SUCCESS - DataType Test
SUCCESS - Dispose pattern test
SUCCESS - KeyInfo Fetch
SUCCESS - Transaction Enlistment
SUCCESS - Guid Test
SUCCESS - InsertTable
SUCCESS - VerifyInsert
SUCCESS - CoersionTest
SUCCESS - ParameterizedInsert
SUCCESS - BinaryInsert (using named parameter)
SUCCESS - VerifyBinaryData
SUCCESS - LockTest
SUCCESS - ParameterizedInsertMissingParams

          Inserting using CommandBuilder and DataAdapter
          -> (10,000 rows) ...
          -> Insert Ends in 210 ms ... Commits in 481 ms

          Inserting using CommandBuilder and DataAdapter
          ->(with identity fetch) (10,000 rows) ...
          -> Insert Ends in 300 ms ... Commits in 201 ms

          Fast insert using parameters and prepared statement
          -> (100,000 rows) Begins ...
          -> Ends in 801 ms ... Commits in 441 ms

          User Function iteration of 120003 records in 240 ms
          Raw iteration of 120003 records in 100 ms
          Intrinsic Function iteration of 120003 records in 70 ms

          User (text)  command executed 397517 times in 1 second.
          UserFunction command executed 570342 times in 1 second.
          Intrinsic    command executed 932032 times in 1 second.
          Intrin (txt) command executed 747247 times in 1 second.
          Raw Value    command executed 1013199 times in 1 second.

          UserAggregate executed 17 times in 1 second.

SUCCESS - UserCollation
SUCCESS - DropTable

Tests Finished.

1.0.48 test

Beginning Test on System.Data.SQLite.SQLiteConnection
SUCCESS - CreateTable
SUCCESS - Full Text Search
SUCCESS - DataType Test
SUCCESS - Dispose pattern test
SUCCESS - KeyInfo Fetch
SUCCESS - Transaction Enlistment
SUCCESS - Guid Test
SUCCESS - InsertTable
SUCCESS - VerifyInsert
SUCCESS - CoersionTest
SUCCESS - ParameterizedInsert
SUCCESS - BinaryInsert (using named parameter)
SUCCESS - VerifyBinaryData
SUCCESS - LockTest
SUCCESS - ParameterizedInsertMissingParams

          Inserting using CommandBuilder and DataAdapter
          -> (10,000 rows) ...
          -> Insert Ends in 411 ms ... Commits in 100 ms

          Inserting using CommandBuilder and DataAdapter
          ->(with identity fetch) (10,000 rows) ...
          -> Insert Ends in 440 ms ... Commits in 131 ms

          Fast insert using parameters and prepared statement
          -> (100,000 rows) Begins ...
          -> Ends in 1312 ms ... Commits in 340 ms

          User Function iteration of 120003 records in 191 ms
          Raw iteration of 120003 records in 130 ms
          Intrinsic Function iteration of 120003 records in 140 ms

          User (text)  command executed 298951 times in 1 second.
          UserFunction command executed 418648 times in 1 second.
          Intrinsic    command executed 599105 times in 1 second.
          Intrin (txt) command executed 458549 times in 1 second.
          Raw Value    command executed 655652 times in 1 second.

          UserAggregate executed 15 times in 1 second.

SUCCESS - UserCollation
SUCCESS - DropTable

Tests Finished.

由测试可知,3.4版的SQLite在很多方面,性能依然要比3.5版的SQLite强不少。但是SQLite 3.5版在OS适配层的改进(引入VFS对象),提高了数据的写入效率,明显的,其Commits的时间总是较少。

结论:
3.4版的SQLite在数据插入较多的应用情况下,效率仍然较好;
3.5版的SQLite在数据写入磁盘方面有很大改进,但其显然在内存数据组织方面还有待改进,插入操作所耗费的时间明显比3.4版要长;

感觉3.4版的SQLite是非常稳定的一个版本。3.5版,看来等等再使用了。

posted @ 2008-02-19 21:00 海天一鸥 阅读(2026) | 评论 (8)编辑

2008年1月17日 #

Windows Live Writer启动错误:无法定位程序输入点IsThreadDesktopComposited 于动态链接库 USER32.dll 上

今天安装了Windows LIve Writer,运行它,出现错误信息如下:

 image

查看事件探查器:

弹出应用程序: WindowsLiveWriter.exe - 无法找到入口: 无法定位程序输入点 IsThreadDesktopComposited 于动态链接库 USER32.dll 上。

没办法,只好先看看User32.dll了:

IsCharAlphaA    0x77d3e5ad    0x0002e5ad    407 (0x197)    user32.dll    C:\WINDOWS\system32\user32.dll   
IsCharAlphaNumericA    0x77d4f209    0x0003f209    408 (0x198)    user32.dll    C:\WINDOWS\system32\user32.dll   
IsCharAlphaNumericW    0x77d2c0f9    0x0001c0f9    409 (0x199)    user32.dll    C:\WINDOWS\system32\user32.dll   
IsCharAlphaW    0x77d1f2ae    0x0000f2ae    410 (0x19a)    user32.dll    C:\WINDOWS\system32\user32.dll   
IsCharLowerA    0x77d3b851    0x0002b851    411 (0x19b)    user32.dll    C:\WINDOWS\system32\user32.dll   
IsCharLowerW    0x77d4f152    0x0003f152    412 (0x19c)    user32.dll    C:\WINDOWS\system32\user32.dll   
IsCharUpperA    0x77d37045    0x00027045    413 (0x19d)    user32.dll    C:\WINDOWS\system32\user32.dll   
IsCharUpperW    0x77d69fb7    0x00059fb7    414 (0x19e)    user32.dll    C:\WINDOWS\system32\user32.dll   
IsChild    0x77d1970e    0x0000970e    415 (0x19f)    user32.dll    C:\WINDOWS\system32\user32.dll   
IsClipboardFormatAvailable    0x77d2f127    0x0001f127    416 (0x1a0)    user32.dll    C:\WINDOWS\system32\user32.dll   
IsDialogMessage    0x77d3c651    0x0002c651    417 (0x1a1)    user32.dll    C:\WINDOWS\system32\user32.dll   
IsDialogMessageA    0x77d3c651    0x0002c651    418 (0x1a2)    user32.dll    C:\WINDOWS\system32\user32.dll   
IsDialogMessageW    0x77d2d8c2    0x0001d8c2    419 (0x1a3)    user32.dll    C:\WINDOWS\system32\user32.dll   
IsDlgButtonChecked    0x77d25d75    0x00015d75    420 (0x1a4)    user32.dll    C:\WINDOWS\system32\user32.dll   
IsGUIThread    0x77d69f77    0x00059f77    421 (0x1a5)    user32.dll    C:\WINDOWS\system32\user32.dll   
IsHungAppWindow    0x77d69a39    0x00059a39    422 (0x1a6)    user32.dll    C:\WINDOWS\system32\user32.dll   
IsIconic    0x77d1be27    0x0000be27    423 (0x1a7)    user32.dll    C:\WINDOWS\system32\user32.dll   
IsMenu    0x77d31328    0x00021328    424 (0x1a8)    user32.dll    C:\WINDOWS\system32\user32.dll   
IsRectEmpty    0x77d1bf26    0x0000bf26    425 (0x1a9)    user32.dll    C:\WINDOWS\system32\user32.dll   
IsServerSideWindow    0x77d1da1d    0x0000da1d    426 (0x1aa)    user32.dll    C:\WINDOWS\system32\user32.dll   
IsWindow    0x77d1b933    0x0000b933    428 (0x1ac)    user32.dll    C:\WINDOWS\system32\user32.dll   
IsWindowEnabled    0x77d1bda2    0x0000bda2    429 (0x1ad)    user32.dll    C:\WINDOWS\system32\user32.dll   
IsWindowInDestroy    0x77d1da74    0x0000da74    430 (0x1ae)    user32.dll    C:\WINDOWS\system32\user32.dll   
IsWindowUnicode    0x77d1c59e    0x0000c59e    431 (0x1af)    user32.dll    C:\WINDOWS\system32\user32.dll   
IsWindowVisible    0x77d1c465    0x0000c465    432 (0x1b0)    user32.dll    C:\WINDOWS\system32\user32.dll   
IsWinEventHookInstalled    0x77d1b1a5    0x0000b1a5    427 (0x1ab)    user32.dll    C:\WINDOWS\system32\user32.dll   
IsZoomed    0x77d1c2b2    0x0000c2b2    433 (0x1b1)    user32.dll    C:\WINDOWS\system32\user32.dll   

我的user32.dll版本为5.1.2600.3099,上面是所有的函数入口,显然,没有IsThreadDesktopComposited,因此可以想见,出现这个错误就不足为怪了。那么看来Windows Live writer加载的DLL不该使用USER32.dll的这个函数,这样,就必须看看DLL的加载过程,以便确定原因:

image

用VC工具一看,发现是c:\windows\system32\MPRAPI.DLL调用了user32.dll中的IsThreadDesktopComposited函数,而刚好我的XP的user32.dll中没有这个函数,所以发生了错误。

解决办法:

将MPRAPI.DLL改名,如MPRAPI.DLL.bak。

重新运行,解决问题。

posted @ 2008-01-17 22:59 海天一鸥 阅读(513) | 评论 (1)编辑

2007年9月15日 #

Web趋势地图

Information Architects发布了一个Web趋势图,按不同的关注点,对互联网界主要的站点,进行了分类,并展示了它们之间的关系。博客园创业,是否能从中看出一些启示呢?

Web地图

posted @ 2007-09-15 19:04 海天一鸥 阅读(1421) | 评论 (11)编辑

2007年9月10日 #

CHM文件打不开

今天由于一个有关Socket通信的程序需要改进,从网络中下载了《C# network programming》电子书,可是居然怎么也打不开。

试了网络中提供的各种方法,均不能解决,后来,把文件copy到C:\  根目录居然打开了。略一思考,发现是原来的路径中包含特殊字符“#”的缘故。

 

如果碰到CHM文件打不开的情况,可能的原因:

  1. 权限不足,可能需要取消对CHM文件的打开验证;
  2. hh.exe 需要的几个OCX需要注册;(网络中有论述)
  3. 文件路径非法:请把文件copy到仅英文字幕的目录,最好没有空格的目录;

C# network programming 对Socket编程做了系统的讲解,如果对.NET环境下的复杂的Socket编程有疑难,不妨查阅查阅,相信有所帮助。这本书有中文版,当当网好像25元:)

要下载电子书,请单击下面的link:

  :http://www.cnblogs.com/Files/SGSoft/csharp_networkingprogramming.rar

posted @ 2007-09-10 21:19 海天一鸥 阅读(448) | 评论 (0)编辑

2007年9月7日 #

Wintellect Collection Classes for .NET now on CodePlex

Training concern Wintellect 将其PowerCollections发布到CodePlex上了。

.NET泛型的一个增强组件,提供了大量.NET中未包含的泛型。

 

Training concern Wintellect has posted a great set of Public License classes for .NET on CodePlex. The goal of the project is to provide generic collection classes that are not available in the .NET framework.
Known as ''Power Collections,'' the software makes heavy use of .NET Generics. Some of the collections included are the

·Deque,
·MultiDictionary,
·Bag,
·OrderedBag,
·OrderedDictionary,
·Set,
·OrderedSet,
·OrderedMultiDictionary
·....

Power Collections is free for all to use within the bounds of the standard Eclipse End user license agreement.
Download information
http://www.codeplex.com/PowerCollections

posted @ 2007-09-07 20:52 海天一鸥 阅读(340) | 评论 (0)编辑

2007年9月3日 #

ICE源码研究

ICE 3.2发布了。

http://www.zeroc.com/forums/announcements/3019-ice-3-2-released.html

使用C++开发分布式应用,ICE是个非常不错的平台。而基于ICE的协议,其分布式通信架构实际支持了多种语言和多种平台,包括C++,JAVA,C#,VB.NET等等。

据称国内有些公司开发的网管软件,或桌面管理软件,都在采用ICE内核。

同样的,使用C#实现的ICE也是非常好的编程学习资料,我整理了一下C#源码,使之能够在VS2005中编译生成。

通过查看ICE的C#源码,发现其很多地方的代码还是有很多优化的可能的,看来ZeroC并没有在.NET上投入太多的精力,C#的实现并无C++的实现那么优雅。站在.NET巨人的肩膀上,ICE的.NET实现远比C++实现所用的代码量要少的多。

但是,ICE的 .NET实现中,对Socket通信的封装非常高效,大家如果在使用Socket通信,不妨借鉴这不妨代码,当然,我也尝试对这部分代码重写,使之使用.NET 2.0的最新API,并支持IPv6等等特性。

下面的链接是ICE for VS 2005 源码项目的下载地址:

ICE 3.2.1 for VS 2005 源码项目

希望能和关注ICE的朋友一起研究,交流心得。

posted @ 2007-09-03 20:17 海天一鸥 阅读(2839) | 评论 (15)编辑