Windows Live and WordPress

Now you can migrate your blog in windows live to wordpress.com...because they partnering toghter

現在Windows Live的Blog部分跟Wordpress合作了, 他有自動畫搬移的過程. 不過看起來account會變成以wordpress....嘖嘖嘖...


GetLastError and FormatMessage and NewLine

When we use FormatMessage to get the system error message by the DWORD(from GetLastError), we will get a LPTSTR that end with NewLine (CRLF). How to convert to be NULL end string? It’s a very easy way to do it:


Code Snippet
  1. CString CGetInfo::GetError(void){
  2.     LPVOID lpMsgBuf;
  3.     DWORD dw = GetLastError();
  5.     FormatMessage(
  9.         NULL,
  10.         dw,
  12.         (LPTSTR) &lpMsgBuf,
  13.         0, NULL );
  14.     CString s = (LPTSTR)lpMsgBuf;
  15.     s.Remove('\r');
  16.     s.Remove('\n');
  17.     return s;
  18. }

當我們在用win32 API裡面的FormatMessage去處理GetLastError傳出來的DWORD 錯誤碼的時候, FormatMessage會回傳一個LPTSTR, 以\r\n結尾的字串, 那怎麼把那個\r\n去掉呢? 其實很簡單, 用CString.Rmove() 兩行輕鬆解決.


FAST Admin Service

I am doing integration between FAST and Umbraco, and consider to decouple the FAST configuration and CMS environment.

Before go to do that I must find out a way to collect administration information from FAST. That is lucky that FAST do provide several web service to provide administration service.

It’s really simple to use the service. usually the admin service is locate at port 16089 and you can just reference the service as “http://host:16089/adminserver/servicename.jws”. and than you can use it as normal web service.

   1: FastAdminPresentationService.PresentationService ps = new FastAdminPresentationService.PresentationService();

   2: CredentialCache cc = new CredentialCache();

   3: cc.Add(new Uri("http:hostname:16089/adminserver/servicename.jws"),"Basic",new NetworkCredential("adminname", "adminpassword"));

   4: ps.Credentials = cc;

Following is the service I using and tested.

CollectionService.getCollectionNames <—get the collection names

IndexProfileService.getClusterNames() <—as name

IndexProfileService.getDeployedIndexProfile(ClusterName) <—get index profile xml

Get Search Profiles:

   1: FastAdminSearchProfilesService.SearchProfileRetrieveFilter filter = new FastAdminSearchProfilesService.SearchProfileRetrieveFilter();

   2: FastAdmiTest.FastAdminSearchProfilesService.SearchProfile[] list = sps.retrieveSearchProfiles(null, false, false, false);

Get the Navigators inside special Search Profile:

First, get the SearchProfile and keep the SearchProfile .publishedViewName, and then Reference PresentationService and get the navigator by publishedViewName as

Navigation navigation = ps.retrieveNavigation(the publishedViewName that we keeped);

Then, the navigation.navigators are what we want to have. If you want the list the same with the Admin Site UI showing, choice the navigators with blocked property be false.


Microsoft Officie 2010 does not support upgrading from a prerelease version of Microsoft Office 2010.

Remember remove Send a smile” before install Office 2010 RTM if you join the Microsoft Connect Office 2010 program. else, you will get this error message:

Setup is unable to proceed due to the following error(s):
Microsoft Officie 2010 does not support upgrading from a prerelease version of Microsoft Office 2010.  You must first uninstall any prerelease versions of Microsoft Office 2010 products and associated technologies.
Correct the issue(s) listed above and re-run setup.


[Umbraco] How to get media URL

Here is one way to do:

string s = string.Empty;
System.Xml.XPath.XPathNavigator n = umbraco.library.GetMedia(m.Id, false).Current;
System.Xml.XPath.XPathNavigator d = n.SelectSingleNode("/node/data[@alias='umbracoFile']");
s=d.InnerXml; // Here is the path


.NET 4.0 Serializing IDictionary

Yes, now we can serializing the object which contain or implement of IDictionay in .NET 4.0.

The different part of code is change to using System.Xaml namespace and the code is more simple, for instance:

using (StreamWriter stream = newStreamWriter("C:\\data.xml")) {

Now the I have to reconsider the power of the web service…


現在我們可以在.NET4.0 的程式碼中Serializing(序列化)含有IDictionary或是繼承自他的物件.

差異的地方是我們必須引用System.Xaml, 新的序列化服務的寫法也變簡單了, 請參考下面程式碼:

using (StreamWriter stream = newStreamWriter("C:\\data.xml")) {

嘖嘖嘖..我現在要好好想想web service的威力了….


System.Net.WebException: The request failed with HTTP status 503: Service Unavailable


  1. ASP.NET application (Web from or call another ASP.NET web service) in IIS6
  2. Complicated network environment
  3. Several web front ends
  4. Every web service call return 503…

Maybe you can try to setup the Internet Explorer proxy settings to bypass every web front end, and also downgrade the IIS from Kerberos to NTLM, and try it again.

Internet Explorer configuration :

  1. Tools –> Internet Options
  2. Connections Tab –> LAN Settings
  3. “Advanced” button inside “Proxy Server” group
  4. Add the web front ends’ domain name into the “Exceptions”

How to downgrade from Kerberos to NTLM:

  1. Open command prompt
  2. Change directory to “C:\Inetpub\Adminscripts
  3. Input:
    cscript adsutil.vbs set w3svc/WebSite/root/NTAuthenticationProviders "NTLM"
  4. About WebSite, it is web site id, you can find it by fowllowing steps:
    1. Open Internet Information Services (IIS) Manager
    2. Click “Web Sites”, and you can found the value in the Identifier column
  5. Input as following command then you can rollback to Kerberos:
    cscript adsutil.vbs set w3svc/WebSite/root/NTAuthenticationProviders "Negotiate,NTLM"



  1. ASP.NET 應用程式呼叫ASP.NET web service, IIS6
  2. 網路環境有點複雜, 而且離我超遠
  3. 很多台web front end
  4. 隨便Call web service都回你503

我後來是這樣解的, 先把所有的web front end server都列入直接連線的部分, 接下來再把所有的web front end的IIS通通設定成NTLM. 先求可以通, 這樣回到Kerberos才有機會跟網管那邊確認問題.

怎麼設定bypass proxy server

  1. 打開IE, 工具->網際網路選項
  2. “連線” 那個頁籤, 選區域網路設定
  3. 按那個進階的按鈕
  4. 在那個例外裡面輸入web front end server的domain name


  1. 打開”命令提示字元”
  2. 將路徑轉換到 “C:\Inetpub\Adminscripts
  3. 輸入:
    cscript adsutil.vbs set w3svc/WebSite/root/NTAuthenticationProviders "NTLM"
  4. 那個WebSite就是站台的ID, 要找的話打開IIS管理工具, 然後點站台, 右邊就會有欄位顯示出來了
  5. 要倒回去Kerberos, 輸入下列命令即可:
    cscript adsutil.vbs set w3svc/WebSite/root/NTAuthenticationProviders "Negotiate,NTLM"


Visual Studio 2010 and 64x

The Redmond company is sticking with a 32-bit exclusive strategy for Visual Studio, at least for the time being, even though it is well aware that 64-bit architectures are becoming mainstream. <----sigh


這家位在Redmond的公司在Visual Studio上將繼續維持32-bit only的策略, 就算64-bit看來一定會是市場的主流. (link點上面那一個) <-- 嘆


UNC and HttpContext.Current.User

If your ASP.NET web site running in a UNC location, and also running the site with windows integrated authentication.

And now, you are trying to get the Http.Current.User. You will get the account who running for Application pool whatever you login for test. I found the only way to get real login account is using Request.ServerVariables[“LOGON_USER”].

Environment: IIS6.0, Umbraco

Does anyone have another solution?

Remove Server From MOSS Farm

There are four way to remove the server from MOSS server farm.

  • First one is disconnect by running the configuration wizard from the start menu. This is the same way to use if you want to leave MOSS 2007 installed on the server but disjoined from the farm.
  • Second on is removes the server if you want to clean up the serer when it can contact the configuration database. This method also uninstalls the SharePoint from the server.
    • ​Use Add/Remove Programs in the control panel.
    • In "Add/Remove Programs", you can remove "Microsoft Office SharePoint 2007", and it wills pop-up a warning, Click Ok to continue.
  • The third method is removing the server from the server farm in the SharePoint Central Administration site. This way is easy and quickly, almost no latency, the action was completed. But this way don’t disconnect the server from the SharePoint database.
  • The last method is more advanced, it will disconnecting the server from the SharePoint configuration database. And then you can format the server or re-install MOSS, whatever you want for the server. The step is very easy:
    • Open a command prompt to c:\program files\common files\Microsoft shared\web server extensions\12\bin (the SharePoint installed path)
    • Run following command:
      psconfig –cmd configdb –disconnect

Actually, I do server remove by the three and last one method, remove the server from MOSS farm by Central administration site, and then disconnected the server from configuration database. It is easy and cleanly, and without reset anything/reboot machine.