2012年12月22日 星期六

推Visual Studio 2012 Quick Launch

推一個新功能"Quick Launch (Ctrl+Q)",這個能增進找功能的速度。
因最近在玩Team Foundation Server (TFS) ,其中有個暫存 (Shelveset) 程式碼的功能,例如: 我想幫同仁改程式,請同仁Shelveset 到TFS上,然後我在自已的電腦上Shelveset下來,可是我一直找不到Shelveset的功能要去那裡找 (菜啊),這時候按下Ctrl+Q -> 輸入 "she" 馬上就出現相關功能,收工~
不多說,請看下面參考圖。




PS: Find Shelvesets的owner可以用"*"符號找到全組的人哦

2012年12月21日 星期五

解決IE showModelDialog的視窗size問題

開發環境

Win 7 + IE 10 Release Preview
IE版本
IE版本

問題描述

這次的問題是在 IE裡使用window.showModalDialog開啟視窗,而此Dialog視窗中有使用Frameset,Frameset是連到另一頁,所以總共有3頁。

  1. index.html 首頁
  2. dialog.html 彈出的網頁
  3. ocx1.html 嵌入在dialog裡的網頁


彈出視窗Size不正確
彈出視窗Size不正確

dialog.html程式碼
dialog.html程式碼
從上圖看,dialogWidth及dialogheight雖然有設定,但是彈出的視窗Size都沒變。

解法方式

修改彈出視窗dialog.html的Frmaeset改為iframe的寫法。

原來的 dialog.html


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
   <frameset id="frameset1" rows="100%" >
    <frame id="input" src="ocx1.html" >
 </frameset>
</html>

修改後的 dialog.html


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
    <iframe src="ocx1.html" id="f1" style="width: 100%; height: 390px; border: 0px;">
    </iframe>
</body>
</html>
成功彈出正確的Size
成功彈出正確的Size

心得

基本上這應該是IE的bug,我在IE 9, IE 10都有遇到過這種情形,另一種消極解法是使用IE相容性檢視,但iframe可以有body的tag,而且好像外面主流還是用iframe比較多,提供您參考。

解決 MVC 4 引動過程的目標傳回例外狀況

開發環境

Win 7 + Visual Studio 2012 + .Net Framework 4 + SQL Server 2008 R2

問題描述

使用MVC 4 預設的Internet Application Templat按下F5進行測試,首頁進的去,直到按下Register或Login會發生錯誤。
Visual Studio 2012 錯誤中斷畫面
Visual Studio 2012 因錯誤而中斷"引動過程的目標傳回例外狀況"
網頁出現系統找不到指定的檔案
網頁出現"系統找不到指定的檔案"

解決方式

將ConnectionString的AttachDBFilename移除
將ConnectionSTring的Data Source改為正確的名稱

原來的

<connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-MvcApplication4-20121221163908;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-MvcApplication4-20121221163908.mdf" providerName="System.Data.SqlClient" />
  </connectionStrings>

移除後

<connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=(local);Initial Catalog=aspnet-MvcApplication4-20121221163908;Integrated Security=SSPI" providerName="System.Data.SqlClient" />
  </connectionStrings>

修改後執行成功囉
修改後執行成功囉

心得

MVC 4預設Template會自動建立DB相關資料,而Register、Login的Action觸發了建立DB的動作,這個動作會失敗感覺上是連不到資料庫,因而我嘗試修改connectionString的字串即成功。