2011年8月8日 星期一

[Visual Studio] *.vshost.exe的用處

轉自http://chuiwenchiu.wordpress.com/2006/04/21/c%E4%B8%80%E5%A0%86-vshost-exe-%E6%98%AF%E5%81%9A%E4%BB%80%E9%BA%BC%E7%94%A8%E5%95%8A/
不知道有沒有人發現 bin/Debug 或 bin/Release 下會出現 [Application Name].vshost.exe,這個檔案是做什麼用的呢?依據官方[1]說法,這個是 Visual Studio 2005 為了以下三個目的所加上去的:
1. 改善除錯效能
2. Partial Trust Debugging:這個沒有用過不太清楚,不過依據文件[1]的描述,好像是為了測試應用程式的安全性必須透過 vshost 來進行初始化…
3. 設計階段可以使用 Immediate Window 進行除錯
簡言之,這個檔案就是為了除錯用。
接下來的問題是,如果程式要出貨想關閉這個功能要怎麼做呢?
只要選取 Project | Properties | Debug,將 Enable the Visual Studio hosting process 選項前的鉤鉤取消即可[3]。

參考資料:
[1] http://msdn2.microsoft.com/en-us/library/ms185331.aspx
[2] http://msdn2.microsoft.com/en-us/library/ms242202.aspx
[3] http://msdn2.microsoft.com/en-us/library/ms185330.aspx
[4] http://blogs.msdn.com/dtemp/archive/2004/08/17/215764.aspx

2011年7月21日 星期四

[JMS] MessageListener.onMessage

A client can register an object that implements the JMS MessageListener interface with a MessageConsumer. As messages arrive for the consumer, the provider delivers them by calling the listener’s onMessage method.

It is possible for a listener to throw a RuntimeException; however, this is considered a client programming error. Well-behaved listeners should catch such exceptions and attempt to divert messages causing them to some form of application-specific ‘unprocessable message’ destination.

The result of a listener throwing a RuntimeException depends on the session’s acknowledgment mode.

AUTO_ACKNOWLEDGE or DUPS_OK_ACKNOWLEDGE - the message will be immediately redelivered. The number of times a JMS provider will redeliver the same message before giving up is provider-dependent. The JMSRedelivered message header field will be set for a message redelivered under these circumstances.
CLIENT_ACKNOWLEDGE - the next message for the listener is delivered. If a client wishes to have the previous unacknowledged message redelivered, it must manually recover the session.
Transacted Session - the next message for the listener is delivered. The client can either commit or roll back the session (in other words, a RuntimeException does not automatically rollback the session).

JMS providers should flag clients with message listeners that are throwing RuntimeExceptions as possibly malfunctioning.

2011年7月5日 星期二

[MySQL] 手動安裝

1. 註冊為系統Service:
    mysqld --install MySQL3 --defaults-file="%CURRENT_DIR%\my-huge.ini"
2. 從系統Service中移除:
    mysqld --remove MySQL3
3. 啟動Service:
    net start MySQL3
4. 關閉Service:
    net stop MySQL3

2011年5月15日 星期日

[C#] byte[] to hex format string

            StringBuilder sb = new StringBuilder(byteData.Length * 2);
            foreach (byte b in byteData)
            {
                sb.AppendFormat("{0:x2}", b);
            }

2011年5月2日 星期一

[C#] log4net 設定檔變數

  %m(message):輸出的日志消息,如ILog.Debug(…)輸出的一條消息
  %n(new line):換行
  %d(datetime):輸出當前语句運行的時刻
  %r(run time):輸出程序從運行到執行到當前語句時消耗的毫秒數
  %t(thread id):當前語句所在的線程ID
  %p(priority): 日志的當前優先級别,即DEBUG、INFO、WARN…等
  %c(class):當前日志對象的名稱
  %L:輸出語句所在的行號
  %F:輸出語句所在的文件名
  %-數字:表示該項的最小長度,如果不夠,則用空格填充

2011年3月2日 星期三

[C#] Thread 執行的method接受參數

1. 要給thread執行的method要能傳入參數Object
public static void StartClient(object messageObj) 
2. 在呼叫Thread.Start()時, 傳入參數
Thread thread = new Thread(AsynchronousClient.StartClient);
thread.Start("456, 121.54068, 25.047867, 0");