2007年6月30日星期六

Quirks mode 比较好和全的CSS教程

http://www.quirksmode.org/css/contents.html
这里是一个比较好的CSS教程的链接,同一个网站上还有站长的其它的信息。

2007年6月27日星期三

Release 和 Debug的另外两篇文章

Surviving the Release Version
By Joseph M. Newcomer.

Learn about the issues and differences between Debug and Release builds.

另一篇是
Release mode debugging with VC++

2007年6月20日星期三

Debug Error! HEAP CORRUPTION DETECTED: before Normal block...


Debug Error!

Program: ...

HEAP CORRUPTION DETECTED: before Normal block(#-1840241472) at 0x004E1550.
CRT detected that the application wrote to memory before start of heap buffer.


Correct the usage of b[-1].

还是动态分配内存的问题,但是用MSVC或Microsoft Visual C++ Express,报错的地方为
delete[] a;
但是,最终找到的出错的地方并不一定和a有关系,错误是另一个动态分配的数组调用时使用了 b[-1],所以上面的错误是 "before Normal..."

2007年6月19日星期二

UNIX Job Control

今天在Emacs里面按了Control-Z,但是我忘了怎样把后台程序弄到前台。
上网查了一下,答案在下面的文章里找到了,原来Control-Z不仅仅对Emacs有效,而是Unix系统里面控制作业进程的通用命令,而将后台的程序调到前台,则需要用%emacs来实现,可以用 jobs 或者 ps查询正在后台执行的作业或进程。
http://www.bu.edu/cc/support/aboutunix/general/jobcontrol/
UNIX Job Control

Any command or any sequence of commands joined by semicolons or by a pipeline is known as a job. Jobs can be suspended and resumed later or they can run "in the background." Background jobs are programs which have been executed in such a way that they return the shell prompt to you while they continue to operate, independent of the shell where they were created. The C shell has a number of built-in functions which enable you to control multiple jobs interactively. Note: running jobs in the background can be useful but may put an excessive load on the system if overused. The 'jobs' command will give you a list of active jobs.

Background and foreground jobs
A program can be run in the background by executing its command line with '&' at the end. For example, you could compile a 'c' program in the background.

% cc other.c -o oter &

%


Then, while the compilation proceeds, you could do some other work, such as edit some files with Emacs.

Later, you might have a new idea and decide that you want to change the source program for your c program to include the new idea. If you don't need the c program to finish its compilation, you could suspend Emacs with ^Z and then stop the compiler by using the kill command.

^Z (Suspend emacs)

Stopped (shell acknowledges)

% jobs

[1] Running cc other.c -o oter (jobs responds)

% kill %1

[1] Killed cc other.c -o oter (kill responds)


While you are at the shell prompt, you could pause to look for mail before resuming emacs:

% mail

No mail for you (mail responds)

% jobs

[1] +Stopped emacs (jobs responds)

% %1 (resume emacs)


In other words, you can resume a job that is stopped by typing %n where 'n' is its job number (the number that the 'jobs' command prints between [ and ]), and you can kill a suspended or stopped job. In fact, if you find yourself caught in a program and don't know how to get out of it, you can suspend the job and then kill it when you get back to the shell prompt. The scope of the 'jobs' command is limited to the shell that it runs under. Job numbers are con- venient references to processes under the control of a single shell.

If you have a job running under another shell that you want to stop, such as at another terminal (for example, you left a job running in the background -- some jobs will keep running), you can use the 'ps' command to find its Process ID (PID, a unique number used by the operating system to identify each process). You can then use the PID to kill the job with the 'kill' command.

% ps

PID TT STAT TIME COMMAND

23444 h4 R 0:00 ps

7158 ic R N 12:33 lisp

%





% kill 7158 (kill a procees by its PID number)

% ps

PID TT STAT TIME COMMAND

23555 h4 R 0:00 ps

%


If you try this method and the job still isn't gone, more drastic methods are needed. Add the -KILL (0r '-9' on some systems) flag as in:

% kill -KILL 7158


No program under UNIX can trap the KILL signal. Just 'kill' sends a -TERM (terminate) signal. This usually works, but if not, -KILL is a sure hit.

Command summary

& run in the background

Z suspend the current job

C interrupt (usually kill) current job

(some programs, such as editors trap

this -- so that a typo won't abruptly

terminate your editing session, losing

your most recent, unsaved work.)



D signal end of input

(log off shell, if issued at top level)



jobs display jobs running from this shell

ps display jobs you are running

ps -g display all jobs and login shells also

kill %n kill a job by job number

kill PID kill a job by process id number

kill -KILL PID a sure kill

('kill -9 PID' on some UNIX versions)


Notes

1. You cannot kill processes you don't own, but you can log in from another terminal and kill a job that has "locked up" your current terminal.
2. Killing your login shell (try 'ps -g') will log you out (Remember, you could force yourself off from a different terminal. When you examine the output of ps, look for the '-csh' commands. If you had an edit session active, you might try 'kill -HUP ###' as that simulates hanging up the 'phone' and most editors will try to preserve interrupted work.)

References
For further information, see the online manual pages or one of the many general books on using the UNIX files system. Information Technology sponsors tutorials on UNIX and other subjects during the academic year and distributes printed handouts on a selection of related subjects.

2007年6月15日星期五

C# XML Comments

C#使用一种新的注释定义,利用定义好的Tag和HTML的关键字,用户可以将注释转化一个很好的文档。
可能Linux下的用户更熟悉Doxygen之类的注释处理工具。
下面的内容是来自微软的MSDN中的一段,简单地介绍了这些注释的语法。
原来的文章里面有更多更高级的应用,可以去看看。
http://msdn.microsoft.com/msdnmag/issues/02/06/XMLC/
There are nine primary tags: , , , , , , , , and .
In this context, the tag is used to describe a type such as a class:
/// 
/// Class that contains functions to do
/// transformations to help files.
///

The C# documentation recommends using to describe a type and a tag to describe a type member. Oddly, if you start a comment before a type using the /// combination, the Visual Studio .NET IDE will still insert a tag. Therefore, tags need to be inserted manually.
The tag is the tag found most often in a C# source file. This tag is used to describe type members, including methods, properties, and fields:
/// 
/// This XmlDocument based attribute contains the
/// XML documentation for the project.
///

The tag can describe types as well, but it is not recommended. The XML comment documentation recommends that the tag be used for describing types.
The tag is used to mark the beginning of an example showing how to use the item. The example can be any valid text, but most often it is a snippet of code:
/// 
///
/// // create the class that does translations
/// GiveHelpTransforms ght = new GiveHelpTransforms();
/// // have it load our XML into the SourceXML property
/// ght.LoadXMLFromFile(
/// "E:\\Inetpub\\wwwroot\\GiveHelp\\GiveHelpDoc.xml");
///

///

If code is used, it is usually marked with a tag. The tag will be discussed in the section on support tags.
The tag documents the exceptions, if any, that the item may throw. If more than one exception may be thrown, then more than one of these tags may be used. Unlike most of the tags, the tag has one attribute, cref. The value of this attribute is the name of the exception that could be thrown. This must be a valid class because the C# parser will verify it and extract the context information to put into the XML documentation. I will explain this later.
I did not throw any exceptions in the code for this article, but here is an example of how the cref attribute can be used with the tag:
/// 
/// Normally, a discussion on any exceptions thrown would go here.
///

The tag describes the parameters of a method or property. It is automatically inserted by the IDE when using the three forward slashes before a method. The tag has one attribute, name, which is simply the same name that the parameter has in the source:
/// The path to the file containing the
/// source XML.
Member access is identified with the tag. The text that is assigned to it sets permission-related descriptions. There is no requirement for the value for this tag. Permission is one possibility, with values such as public, private, protected, and so on. Scope is another possible value, with information about whether the method is static. However, you are free to put whatever value you must have here.
The tag has one attribute—cref. The documentation describes the use of cref in this context as "a reference to a member or field that is available to be called from the current compilation environment." It is usually set to System.Security.PermissionSet:
/// Public
/// Access

The tag is similar to the tag, but it's used to describe what the method or property returns:
/// The HTML for a list of types based on the XML

/// documentation.
The tag specifies "other" links related to the same topic. This tag usually does not include a text value, just a cref attribute that specifies a reference to a symbol. This could be a type, member, field, and so on.
/// 
The XML compiler will identify the content of the symbol and use it accordingly in the compiled XML documentation. I'll discuss this again in the section on the XML documentation file.

2007年6月11日星期一

CSS的一个网站Eric Meyer

http://meyerweb.com/eric/css/

网站上有不少CSS的内容,教程,范例等等。

CSS Work

css/edge
A collection of cutting-edge CSS-driven design demos, created by yours truly as a way of showing just how far you can take CSS in a browser that fully supports it. Some pages may look a little weird in your browser, but that's to be expected when you're on the edge...
CSS References
Sure, you can go get the original versions, or you could use my local frames-based wrappers to quickly find what you want. If the Sidebar Tabs (see below) aren't an option for you, then feel free to give these a spin!
Inline model document
A terse, but hopefully complete, description of how the CSS inline box model really works. This might become the basis for a section of CSS3, assuming I ever get around to actually writing it.
W3C CSS2 Test Suite Prototyping
The beginnings of the next official W3C CSS test, this one covering CSS1 and CSS2 instead of just CSS1.
CSS Tests
A fairly large collection of test files I've accumulated over the years. The test subjects run the gamut from CSS1 to CSS3, and are rarely if ever documented. Feel free to explore to your heart's content. Note: Eric is not responsible for anything that happens to your browser or your happiness with it as a result of your loading up these tests.
Articles by Eric
Local copies of CSS articles, as well as other writing I've done.
Books by Eric
Including Eric Meyer on CSS, More Eric Meyer on CSS, Cascading Style Sheets: The Definitive Guide, Second Edition and Cascading Style Sheets 2.0 Programmer's Reference.

WebKit - 苹果电脑的浏览器引擎 - 开源

http://webkit.org/

现在主要有三个浏览器引擎:微软的IE使用的,Mozilla Firefox使用的,和苹果电脑上的Safari使用的Webkit

现在,Safari也有了Windows系统下运行的版本了。


WebKit is an open source web browser engine. WebKit is also the name of the Mac OS X system framework version of the engine that's used by Safari, Dashboard, Mail, and many other OS X applications. WebKit's HTML and JavaScript code began as a branch of the KHTML and KJS libraries from KDE. This website is also the home of S60's S60 WebKit development.

NPLOT Charting Library for .NET - VB.NET / C# / C++ / J#

NPLOT Charting Library for .NET - VB.NET / C# / C++ / J#
一个免费的图表绘制,特别是科学绘图的库,可供多种语言调用,甚至有GTK#的支持。图表可以输出于网页,windows视窗,图片文件中。
http://netcontrols.org/nplot/wiki/

下载:http://netcontrols.org/nplot/wiki/index.php?n=Main.DownloadArea
其示例文件中包含了C++和C#的例子。
这里有一个画随机数图像的网页示例:http://netcontrols.org/nplot/live_example/TestNPlot.aspx

ZedGraph


ZedGraph 是一个C#绘图库,供绘制二维图表之用。
.NET中比较常用的商业绘图库是Dundas Chart,当然,它是要花钱的。
ZedGraph是开源的,不过也为商业应用留了余地。
详细的请到ZedGraph的网站上去查:
http://zedgraph.org/wiki/index.php?title=Main_Page
ZedGraph在CodeProject上的介绍文章:
http://www.codeproject.com/csharp/zedgraph.asp
ZedGraph的示例如
http://zedgraph.sourceforge.net/samples.html
ZedGraph的下载中还包含了一个demo,里面有大量的Sample,并且附带源代码。
下载:
http://sourceforge.net/projects/zedgraph/

下面是ZedGraph的英文介绍
Are you looking for a way to draw in .Net? Here's yet another charting class library with a high degree of configurability that is also easy to use.

ZedGraph is a set of classes, written in C#, for creating 2D line and bar graphs of arbitrary datasets. The classes provide a high degree of flexibility -- almost every aspect of the graph can be user-modified. At the same time, usage of the classes is kept simple by providing default values for all of the graph attributes. The classes include code for choosing appropriate scale ranges and step sizes based on the range of data values being plotted.

ZedGraph also includes a UserControl interface, allowing drag and drop editing within the Visual Studio forms editor, plus access from other languages such as C++ and VB. ZedGraph is licensed under the LGPL.

2007年6月8日星期五

谁发明了对数 Log

1614年,苏格兰数学家Napier发明了对数,来将乘法和除法变为加法和减法以方便计算。

2007年6月7日星期四

/usr/bin/ld: cannot find -l

使用Linux中的g++处理一个在Windows下的Cygwin的g++可以成功处理的Makefile时,出现了链接库的错误:

g++ a.o -L. -lsqlite3 -o exename
/usr/bin/ld: cannot find -lsqlite3
collect2: ld returned 1 exit status
make: *** [exename] Error 1
这是一个编译时候的路径错误,我把从SQLite官方网站上下载的sqlite3.so放在了Makefile的同目录下。
在 Linux下,默认的链接库的名字为 libsqlite3.so所以我把库名改了。
这时出现如下的错误:
./libsqlite3.so: undefined reference to 'pthread_create'
./libsqlite3.so: undefined reference to 'pthread_getspecific'
./libsqlite3.so: undefined reference to 'dlclose'
./libsqlite3.so: undefined reference to 'pthread_key_create'
./libsqlite3.so: undefined reference to 'dlopen'
./libsqlite3.so: undefined reference to 'dlsym'
./libsqlite3.so: undefined reference to 'pthread_join'
./libsqlite3.so: undefined reference to 'pthread_setspecific'
从SQLite官方网站上下载的这个预编译过的so链接库需要同时链接 libpthread.so
所以命令改为
g++ a.o -lpthread -L. -lsqlite3 -o exename
, 只剩下 dl开头的一些错误。
所以在命令中添加链接库 libdl.so的命令,最后的命令如下
g++ a.o -lpthread -ldl -L. -lsqlite3 -o exename


现在编译链接没有错误了,可以成功生成 exename可执行文件,但可执行文件却有新的错误:
./exename: error while loading shared libraries: libsqlite3.so: cannot open shared object file: No such file or directory.


也就是说,还要把libsqlite3.so这个文件拷贝到/usr/lib中,这个程序才可用。

linker input file unused because linking not done

我在Windows下使用SQLite编了个C++程序,在编写Makefile并使用cygwin 中的 g++进行编译链接时遇到如下的错误:
linker input file unused because linking not done
我的语句是 g++ -c a.cpp -lsqlite3

到网上查了一下,问题出在链接数据库的语句不应出现在编译语句里面。 上面的语句里面有 -c 即编译 compile,所以命令会忽略掉所有的 -l 链接库的命令。

而要链接数据库,应该在生成可执行文件时才使用。
正确的使用链接的语句应该是 g++ a.o -L. -lsqlite3 -o exename

2007年6月3日星期日

又一个内存分配的问题

错误内容如下:
Debug Assertion Failed!

Program: ... \*.exe
File:dbgheap.c
Line: 1044
Expression: _CrtIsValidHeapPointer(pUserData)

For information how your program can cause an assertion failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
在调试的时候,点击 Retry,程序找到文件 ...\VC98\CRT\SRC\DBGHEAP.C
停在了
/*
* If this ASSERT fails, a bad pointer has been passed in. It may be
* totally bogus, or it may have been allocated from another heap.
* The pointer MUST come from the 'local' heap.
*/
_ASSERTE(_CrtIsValidHeapPointer(pUserData));

也就是刚才报错的那个程序,但是有注释提醒了一些处理。

已知的错误可能:
内存非配的错误。
程序中使用了两个类,都有动态创建的内容。
其中在一个类A中动态创建了另一个类B的对象,然后又动态创建了这个类B的对象的几个动态数组c。
在这个错误出现之前,曾经想用B.setDim(aNumber)来为c分配内存,但是在Debug Mode下有如下的错误。
Unhandled Exception in GasMain.exe: 0xC0000005: Access Violation.
内存分配失败。
但是,如果直接使用 B.c=new double[aNumber];却没有错误。
但是出现了本文最初提到的错误。
解决方法(其实是错误原因找到了):
在Workspace里面的External Dependencies下面有一个b.h头文件,这个文件应该与 B类的头文件一样,而且因为已经有了 B.h,应该没有必要在这个地方出现这个同样的头文件,可能是我添加文件时出错了。而且这两个头文件是不一样的。

更正这个错误后,上面的错误就消失了。

2007年6月2日星期六

ASP.NET 1.1 升级到2.0的问题

在Google上搜索ASP.NET 1.1 升级到2.0,竟然大多数都是:
从ASP.NET 1.1升级到ASP.NET 2.0要考虑的Cookie问题,感兴趣的可以去搜索一下。
不过总算在这些文章的标题中找到了一个总结性的文章,记在下面:

Asp.net 1.1 升级至ASP.NET 2.0 十个问题总结

Asp.net 1.1 升级至ASP.NET 2.0 十个问题总结
  1.Global.asax文件的处理形式不一样

   转化后将出现错误,在vs2003中Global.asax具有代码后置文件,2.0下, 将代码分离文件移到 App_Code 目录下,以便使其自 动变为可通过应用程序中的任意 ASP.NET 页面访问。“Code-behind”属性将从 ASAX 文件的指令中删除。vs2005则直接把代码 写在Global.asax。所以需要删除转化过来的文件重新加入,并把相应的代码copy过来。

  2.2.0没有了项目文件。

  在 1.1 应用程序中,项目文件包含生成设置、对外部程序集的引用以及项目中的文件列表。而在 2.0 应用程序中,不再需要版本设置和文件列表,因为 Web 项目目录下的所有文件都被视为 Web 项目的一部分。

  3.代码分离模式。

  在 ASP.NET 1.1 中,代码分离模式使内容(例如 test.aspx)与代码(例如 test.aspx.cs)分离。内容页面从代码分离页面继承而来,代码分离页面包含用户和设计器生成的代码。

   ASP.NET 2.0 通过使用局部类来增强代码分离模式,使用 partial 关键字可以将单个类的代码分隔到两个独立的文件中。它允许一个类跨 越多个文件。在新的代码分离模式中,内容页面从编译的类继承而来,它由相应的代码分离页面以及自动生成的存根文件组成,存根文件用于为内容页面中使用的控 件定义字段声明。此项更改使自动生成的代码与用户的代码分离,并且使代码分离页面显著变小且更加简洁。局部类结构还降低了由于编辑设计器生成的代码而不小 心破坏页面的风险。

  如果出错请检查是否有partial 关键字,否则添加 partial 关键字。

  4.语法检查。

  asp.net1.1程序,编译时不会检查aspx、aspcx等文件中的语法错误,而vs2005编译时会检查项目中所有的aspx、aspcx等文件中的语法,所以如果有语法错误,会导致编译无法通过。

  5.控件声明。

  如果在 .aspx 页面上声明了所有控件,则从代码分离文件中删除所有控件声明,否则报错:重复定义。

  6.(仅限于 C#)将事件挂钩代码从代码分离文件的 InitialzeComponent 函数移到 .aspx 页面中。

   请注意,此操作不适用于自动调用的事件,包括 Page_Init、Page_Load、Page_DataBind、Page_PreRender、 Page_Unload、Page_Error、Page_AbortTransaction 和 Page_CommitTransaction。

  7. 部署方式(预编译、完整编译、可更新站点等)。

   在 1.x 中,Web 应用程序是作为一个大型程序集而预编译和部署的。内容页面(*.aspx)不在服务器上编译,但可以在服务器上编辑。借助新的 页面编译模式和目录结构,您就可以使用多种不同的配置来部署 ASP.NET 2.0 应用程序。一种情况,您可以预编译所有的 ASPX 页面并部署由 完全编译好的程序集组成的 Web 应用程序。在这种模式下,您不能在服务器上轻松地更改该应用程序。另一种情况,您可以在不预编译任何代码的情况下部署 应用程序。在这种配置下,您可以直接在服务器上更改该应用程序中的 .aspx 页面、代码分离文件或其他任何代码。当用户请求服务器上的页面时,页面将 被动态编译。

  8.将 .aspx 页面中的所有 CodeBehind 属性更改为 CodeFile 属性

  CodeBehind: 指定包含与页关联的类的已编译文件的名称。该属性不能在运行时使用。
提供此属性是为了与以前版本的 ASP.NET 的兼容,以实现代码隐藏功能。在 ASP.NET 2.0 版中,应改用 CodeFile 属性指定该源文件的名称,同时使用 Inherits 属性指定该类的完全限定名称。

  CodeFile: 指定指向页引用的代码隐藏文件的路径。此属性与 Inherits 属性一起使用可以将代码隐藏源文件与网页相关联。此属性仅对编译的页有效。

  9.将所有独立的代码文件和AssemblyInfo.cs都被移到 App_Code 目录下。

   但运行转换向导之后,您可能会发现某些代码分离文件(例如,*.aspx.cs 或 *.ascx.vb)被移到 App_Code 目录下。这表明代 码分离文件的内容页面含有格式不正确的 Codebehind 指令,并且没有进行正确设置。也就是说,转换向导不能确定该代码分离文件是否实际绑定到某 个特定的 .aspx 页面。

  10.Web 服务

  在 ASP.NET 1.x 中,Web 服务 (.asmx) 自动拆分到空白标题页面 (.asmx) 和包含实际方法的代码分离文件中。

  Asp.net2.0下:

a)将代码分离类移到 App_Code 目录下,以便使其自动变为可通过应用程序中的任意 ASP.NET 页面访问。
b)更改 .asmx 文件中的 CodeBehind 属性,以便指向新位置。(请注意,代码分离文件不使用局部类,因此继续使用 CodeBehind 属性。)
c)将所有的默认、Friend 和 Internal 范围的声明更改为 Public。


文章来自: 本站原创
引用通告地址: http://www.csafe.cn/trackback.asp?tbID=1174
Tags: Asp.Net 解决方案