Chunyi's profile沿途都是生活的风景PhotosBlogListsMore Tools Help

Blog


    June 12

    治愈IIS疑难杂症

    从上周陆陆续续整理IIS,无论Xp还是vista都是那么难搞,

    我上msdn forumgoogle和各种论坛查看N多种症状和解决方法,甚至都求助我们的IT,仍然没有搞定,真是郁闷至极

    还好现在终于柳暗花明了

    ===================================================================

     

    在屡屡的尝试下,其实发现这个方法最好 sorry,我没有记下链接,所以只能感谢无名的原作者了)

    How To Reinstall IIS
    如何重新安装IIS,有的时候IIS出现严重错误,比如metabase坏掉,又没有备份....
    一般的做法,直接在控制面板添加删除程序中卸载IIS重装。

    这样并不是保险的做法,很多人在重装IIS后问题依旧。
    所以建议在任何情况下都用以下步骤重新安装IIS
    1
    、把IIS卸载。
    2
    、把 %windir%\system32\inetsrv 删除。
    3
    、把%windir%\iisX.log删除,X IIS版本。
    4
    、把 \inetpub\ 目录删除。
    (以上操作可以在安全模式中进行。如果不是在安全模式可能要重新启动,然后不断地删……

    5、重装IIS 

    因为我的IIS至少是这样搞定的,一定要彻底清除所有IIS相关的文件和目录,不然一切都是白搭;

     

     

    现在总结一些我的经验和出现过的苦恼

    而我出现的IIS问题就是经典的HTTP500Server Application Error see below

    Server Application Error

    The server has encountered an error while loading an application during the processing of your request. Please refer to the event log for more detail information. Please contact the server administrator for assistance.  

    在解决其中学了几点技巧, 尽管大部分在我的case中都不work

    1) turn off Show Friendly HTTP Error messages in IE settings to get the real error message

    2) view event log, (control plane->computer management->Event View->System) to find what happens with your IIS.

     

    The classic warning W3SVC 36 found as below

    Event Type: Warning
    Event Source: W3SVC
    Event Category: None
    Event ID: 36
    Description:
    The server failed to load application '/LM/W3SVC'.  The error was 'The specified metadata was not found.

    Or

    The server failed to load application '/LM/W3SVC/1/ROOT/IISHELP'.  The error was 'No such interface supported.

    Or

    The server failed to load application '/LM/W3SVC/1/ROOT/IISHELP'.  The error was 'Class not registered.

     According to warning description, you may search lots of solutions (most are similar), though most didn't work in my case, because the root problem is something wrong with IIS installation in my case.

    3) Another soultion I found from Internet http://msmvps.com/blogs/bernard/archive/2005/03/22/39216.aspx

    Is to reinstall the below package (these package can be found from mmc->component service->computer->my computer->Com+ Applications)

    IIS In-Process Applications
    IIS Out-of-Process Pooled Applications 
    IIS Utilities

     Steps as below:

    ·         comand line "msdtc -resetlog"

    ·         rundll32 wamreg.dll, CreateIISPackage

    ·         rundll32 regsvr32 asptxn.dll

    ·         IISRESET

    4) Another solution is to manage user account (http://www.5dmail.net/html/2004-12-7/2004127164710.htm), and the reason is that IIS, COM+, and Active Directory reuse the account IWAM_YOURMACHINENETBIOS, so we need manually keep them consistent

    a.    更改Active DirectoryIWAM_MYSERVER账号的密码  (Actually, Active Directoy is available in all machines)
    (1)
    选择开始”->“程序”->“管理工具”->"Active Directory用户和计算机",启动“Active Directory用户和计算机管理单元。
     
    (2)
    单击“user”,选中右面的“IWAM_MYSERVER”,右击选择重设密码(T)...”,在跳出的重设密码对方框中给IWAM_MYSERVER设置新的密码,这儿我们设置成“Aboutnt2001”(没有引号的),确定,等待密码修改成功。
     

    b.
    同步IIS metabaseIWAM_MYSERVER账号的密码
     

    c:\Inetpub\AdminScripts>adsutil SET w3svc/WAMUserPass "Aboutnt2001" 


    c.同步COM+应用程序所用的IWAM_MYSERVER的密码 

    cscript synciwam.vbs -v

    5) 最好的方案啊,至少对我而言,那就是前面说的IIS reinstall

     

     

    也许真的是会者不难,总之在无尽的搜索和尝试中真是累死我了

     

     

     

     

     

     


     
     

    June 08

    Location Based Service

    很有兴趣去试试Location based service,说白了主要是地图上的操作,
    发现两个工具:MapPoint Location Service 和 Google Map API,
     
    At first, I choose MapPoint (no reason), However, I failed to connect MapPoint Server (all accounts given failed);
    and then I tried to build a MapPoint Location Server, see http://msdn2.microsoft.com/en-us/library/ms955257.aspx
    Oh my god, I know it is not easy to play:(
     
    Then, I turn to google map, and easily obtained Sample code using google API from http://www.google.com/apis/maps/,
    and docs can be provided in details.
     
    So I understand the trend result of Google MAP vs MapPoint (from Google Trends)...
     
     
     
     
     
     
    December 05

    OS Archive

    OS Archive
     
    基于8086的IBM PC开机过程: http://xianjunzhang.blog.sohu.com/21541107.html
    (limited to 1M ROM)
    0xf000:0xfff0: the first instruction, jmp to the BIOS bootloader,
     jmp 0xf000:0x****, 0x**** depends on bios bootloader size...
     
     
    ASM- Refer to IA-32 (vol 1,2,3),
    esp Vol.3: system programming
    (Also refer to IA-64)
     
     
    September 03

    COM--Example for vitural function and vtable(zz)

    outline: virtual function and vtable are very imporattan concepts in c++. Actually all complier obey the fact-rule
    on vtable, which provides the basis for cross-language cooperation.
    If exploring more, please try to Disassembly in DEBUG mode, and find out what is the binary implementation. 

     
    深入研究虚函数和vtable

    国防科技大学计算机学院     褚瑞

            在面向对象的C++语言中,虚函数(virtual function)是一个非常重要的概念。因为它充分体现了面向对象思想中的继承和多态性这两大特性,在C++语言里应用极广。比如在微软的MFC类库中,你会发现很多函数都有virtual关键字,也就是说,它们都是虚函数。难怪有人甚至称虚函数是C++语言的精髓。

            那么,什么是虚函数呢,我们先来看看微软的解释:

            虚函数是指一个类中你希望重载的成员函数,当你用一个基类指针或引用指向一个继承类对象的时候,你调用一个虚函数,实际调用的是继承类的版本。

                                                                   ——摘自MSDN

            这个定义说得不是很明白。MSDN中还给出了一个例子,但是它的例子也并不能很好的说明问题。我们自己编写这样一个例子:

    #include "stdio.h"

    #include "conio.h"

     

    class Parent

    {

    public:

      char data[20];

      void Function1();

      virtual void Function2();   // 这里声明Function2是虚函数

    }parent;

    void Parent::Function1()

    {

      printf("This is parent,function1\n");

    }

    void Parent::Function2()

    {

      printf("This is parent,function2\n");

    }

     

    class Child:public Parent

    {

      void Function1();

      void Function2();

    } child;

    void Child::Function1()

    {

      printf("This is child,function1\n");

    }

    void Child::Function2()

    {

      printf("This is child,function2\n");

    }

     

    int main(int argc, char* argv[])

    {

      Parent *p;  // 定义一个基类指针

      if(_getch()=='c')     // 如果输入一个小写字母c

           p=&child;         // 指向继承类对象

      else

           p=&parent;       // 否则指向基类对象

    p->Function1();   // 这里在编译时会直接给出Parent::Function1()

                                       入口地址。

      p->Function2();    // 注意这里,执行的是哪一个Function2

      return 0;

    }

            用任意版本的Visual C++Borland C++编译并运行,输入一个小写字母c,得到下面的结果:

    This is parent,function1

    This is child,function2

          为什么会有第一行的结果呢?因为我们是用一个Parent类的指针调用函数Fuction1(),虽然实际上这个指针指向的是Child类的对象,但编译器无法知道这一事实(直到运行的时候,程序才可以根据用户的输入判断出指针指向的对象),它只能按照调用Parent类的函数来理解并编译,所以我们看到了第一行的结果。

            那么第二行的结果又是怎么回事呢?我们注意到,Function2()函数在基类中被virtual关键字修饰,也就是说,它是一个虚函数。虚函数最关键的特点是“动态联编”,它可以在运行时判断指针指向的对象,并自动调用相应的函数。如果我们在运行上面的程序时任意输入一个非c的字符,结果如下:

    This is parent,function1

    This is parent,function2

            请注意看第二行,它的结果出现了变化。程序中仅仅调用了一个Function2()函数,却可以根据用户的输入自动决定到底调用基类中的Function2还是继承类中的Function2,这就是虚函数的作用。我们知道,在MFC中,很多类都是需要你继承的,它们的成员函数很多都要重载,比如编写MFC应用程序最常用的CView::OnDraw(CDC*)函数,就必须重载使用。把它定义为虚函数(实际上,在MFCOnDraw不仅是虚函数,还是纯虚函数),可以保证时刻调用的是用户自己编写的OnDraw。虚函数的重要用途在这里可见一斑。

          在了解虚函数的基础之上,我们考虑这样的问题:一个基类指针必须知道它所指向的对象是基类还是继承类的示例,才能在调用虚函数时“自动”决定应该调用哪个版本,它是如何知道的?有些讲C++的书上提到,这种“动态联编”的机制是通过一个“vtable”实现的,vtable是什么?微软在关于COM的文档里这样描述:

            vtable是指一张函数指针表,如同C++中类的实现一样,vtable中的指针指向一个对象支持的接口成员函数。       

                                                                   ——摘自MSDN

            很遗憾,微软这次还是没有把问题说清楚,当然,上面的文档本来就是关于COM的,与我们关心的问题不同。

            那么vtable是什么?我们先来看看下面的实验:

            在前面的示例程序中加一句 printf(“%d”,sizeof(Child)); 运行,然后去掉Function2()前的virtual关键字,再运行,得到这样的结果:当Function2定义成虚函数的时候,结果是24,否则结果是20。也就是说,如果Function2不是虚函数,一个Child类的示例所占空间的大小仅仅是它的成员变量data数组的大小,如果Function2是虚函数,结果多了4个字节。我们使用的是32位的Visual C++ 6.04个字节恰好是一个指针,或者是一个整数所占的空间。

            那么这多出来的四个字节究竟起到了什么作用?

            Visual C++打开前面的示例程序,在main函数中p->Function1(); 一句前面按F9设断点,按F5开始调试,输入一个小写c,程序停到了我们设的断点上。找到Debug工具条,按Disassembly按钮