說明:
編輯WPF的xaml,使用GroupBox編輯控制項出現該錯誤。
原因:
GroupBox內只能有一個element,因此無論Panel或Grid都只能放一個,可以在Panel或Grid內放入子element即可。例:
<GroupBox>
<StackPanel>
<UniformGrid></UniformGrid>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
</Grid>
</StackPanel>
</GroupBox>
參考資料:
http://stackoverflow.com/questions/1356036/groupbox-in-wpf-can-only-contain-one-element
2016年2月22日 星期一
2016年2月16日 星期二
[Visual Studio] 如何自動同步程式發行版本與最小必要版本? (強制更新發行程式) / minimum required version auto-increment in the clickonce deployment
說明:
使用clickonce發行程式安裝檔,想強制更新client程式,需指定最小必要版本,因發行版本可自動遞增,如何讓最小必要版本同步發行版本? 讓client程式可自動更新。
做法:
1. 方案總管中的專案圖示 -> 右鍵 -> 卸載專案
2. 一樣專案圖示 -> 右鍵 -> 編輯xxx.csproj
3. 在<Project>與</Project>的tag中插入以下設定:
4. 儲存並關閉csproj -> 發行後檢視部署資訊清單(xxx.application) -> 檢視minimum required version是否有值且正確。
參考資料:
http://stackoverflow.com/questions/202491/automatically-increment-minimum-required-version-in-a-clickonce-deployment
http://stackoverflow.com/questions/202491/automatically-increment-minimum-required-version-in-a-clickonce-deployment
使用clickonce發行程式安裝檔,想強制更新client程式,需指定最小必要版本,因發行版本可自動遞增,如何讓最小必要版本同步發行版本? 讓client程式可自動更新。
做法:
1. 方案總管中的專案圖示 -> 右鍵 -> 卸載專案
2. 一樣專案圖示 -> 右鍵 -> 編輯xxx.csproj
3. 在<Project>與</Project>的tag中插入以下設定:
<Target Name="AutoSetMinimumRequiredVersion" BeforeTargets="GenerateDeploymentManifest">
<FormatVersion Version="$(ApplicationVersion)" Revision="$(ApplicationRevision)">
<Output PropertyName="MinimumRequiredVersion" TaskParameter="OutputVersion" />
</FormatVersion>
<FormatVersion Version="$(ApplicationVersion)" Revision="$(ApplicationRevision)">
<Output PropertyName="_DeploymentBuiltMinimumRequiredVersion" TaskParameter="OutputVersion" />
</FormatVersion>
</Target>
設定是將ApplicationVersion(如: 1.0.0.%2a)與ApplicationRevision(修訂號,如: 2)合併成最終發行版號,寫入最小必要版本,再寫入部署資訊清單內的最小必要版本屬性。4. 儲存並關閉csproj -> 發行後檢視部署資訊清單(xxx.application) -> 檢視minimum required version是否有值且正確。
參考資料:
http://stackoverflow.com/questions/202491/automatically-increment-minimum-required-version-in-a-clickonce-deployment
http://stackoverflow.com/questions/202491/automatically-increment-minimum-required-version-in-a-clickonce-deployment
2016年2月4日 星期四
[.NET] DateTimeOffset與DateTime的差異/ What's the difference between DateTimeOffset and DateTime
說明:在.NET framework中用來處理日期與時間的class有DateTimeOffset跟DateTime,究竟差在哪?
說明:
DateTime:好像最直覺用來處理時間的class,但有下列缺點:
● 轉UTC或LocalTime時,可能會與預期不符,如:
DateTime dt = new DateTime(2016,2,4,22,0,0);
dt.ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss"); //顯示為2016/2/5 06:00:00
這是因為DateTime內只儲存Ticks(從0001/1/1起的時間單位)跟Kind,此時Kind為Unspecified,呼叫ToLocalTime()將dt視為UTC時間,依據本地電腦時區+8,因此出現該情形。若改為:
DateTime dt = DateTime.Now; //Kind為Local,代表本地時間,ToLocalTime()就ok。
● DateTime.CompareTo(),不會考慮時區,單純比較Ticks。
DateTimeOffset:特定時間需指定時區offset,如:
DateTimeOffset dt = new DateTimeOffset(2016,2,4, 22, 0, 0, new TimeSpan(8,0,0));
若有跨時區轉換,用DateTimeOffset是最保險的做法。
參考資料:
http://blogs.msdn.com/b/davidrickard/archive/2012/04/07/system-datetime-good-practices-and-common-pitfalls.aspx
說明:
DateTime:好像最直覺用來處理時間的class,但有下列缺點:
● 轉UTC或LocalTime時,可能會與預期不符,如:
DateTime dt = new DateTime(2016,2,4,22,0,0);
dt.ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss"); //顯示為2016/2/5 06:00:00
這是因為DateTime內只儲存Ticks(從0001/1/1起的時間單位)跟Kind,此時Kind為Unspecified,呼叫ToLocalTime()將dt視為UTC時間,依據本地電腦時區+8,因此出現該情形。若改為:
DateTime dt = DateTime.Now; //Kind為Local,代表本地時間,ToLocalTime()就ok。
● DateTime.CompareTo(),不會考慮時區,單純比較Ticks。
DateTimeOffset:特定時間需指定時區offset,如:
DateTimeOffset dt = new DateTimeOffset(2016,2,4, 22, 0, 0, new TimeSpan(8,0,0));
若有跨時區轉換,用DateTimeOffset是最保險的做法。
參考資料:
http://blogs.msdn.com/b/davidrickard/archive/2012/04/07/system-datetime-good-practices-and-common-pitfalls.aspx
2015年12月30日 星期三
[VS/TFS] 連接TFS出現無法切換伺服器,忙碌中訊息/unable to switch server at this time, team explorer is busy
說明:
使用VS 2008安裝Team Explorer 2008與向上相容TFS 2010套件連接TFS 2010,在新增伺服器時,輸入TFS URL後,出現該錯誤訊息。
解法:
將輸入的URL最後的反斜線拿掉即可。例:http://[ServerName]:8080/tfs/,移除/。
因為Team Explorer 2008比較舊,無法處理/,造成無法連線。
可參閱[1]:
參考資料:
使用VS 2008安裝Team Explorer 2008與向上相容TFS 2010套件連接TFS 2010,在新增伺服器時,輸入TFS URL後,出現該錯誤訊息。
解法:
將輸入的URL最後的反斜線拿掉即可。例:http://[ServerName]:8080/tfs/,移除/。
因為Team Explorer 2008比較舊,無法處理/,造成無法連線。
可參閱[1]:
Warning: Although the Admin Console displays the URL with a final slash, "/", the older clients do not take handle the slash and will not connect.
It is possible to connect to the default Team Project Collection by providing the server name only. This method is limited, as it only allows connection to one of the Team Project Collections in a TFS Instance.
參考資料:
- http://blogs.msdn.com/b/team_foundation/archive/2010/04/13/compat-matrix-for-2010-rtm-team-foundation-server-to-team-explorer-2008-and-2005.aspx
- https://social.msdn.microsoft.com/Forums/zh-TW/7b912531-efee-470e-bcd1-0a3d44b814b5/unable-to-switch-servers-at-this-time-team-explorer-is-busy?forum=tfssetup
- http://blogs.msdn.com/b/jasonba/archive/2009/08/10/how-to-connect-to-a-tfs-2010-server-from-a-2008-team-explorer-client.aspx
[.NET/IIS] runtime修改ASP.NET專案的web.config,對request與session的影響?
說明:在Server上修改web.config或更改bin下的dll檔,對於request與session會有什麼影響?
參考如下:
會起新的Application Domain,Application Pool不動(working process不變)。
● app domain在卸除前,會處理完佇列中的request,新的request由新的app domain起來處理。
● in-process session會不見,因此建議將session存放於out-of-process,如session state server或DB。
參考資料:
https://blogs.msdn.microsoft.com/tess/2006/08/02/asp-net-case-study-lost-session-variables-and-appdomain-recycles/
http://huan-lin.blogspot.com/2010/11/app-pool-vs-app-domain.html
http://stackoverflow.com/questions/27705527/does-editing-a-web-config-file-trigger-an-overlapping-recycle-or-a-startstop-of
參考如下:
會起新的Application Domain,Application Pool不動(working process不變)。
● app domain在卸除前,會處理完佇列中的request,新的request由新的app domain起來處理。
● in-process session會不見,因此建議將session存放於out-of-process,如session state server或DB。
參考資料:
https://blogs.msdn.microsoft.com/tess/2006/08/02/asp-net-case-study-lost-session-variables-and-appdomain-recycles/
http://huan-lin.blogspot.com/2010/11/app-pool-vs-app-domain.html
http://stackoverflow.com/questions/27705527/does-editing-a-web-config-file-trigger-an-overlapping-recycle-or-a-startstop-of
2015年11月26日 星期四
[.NET] VS錯誤訊息出現「重試次數超過10次。作業失敗。」、「由於另一個處理序正在使用檔案,所以無法存取該檔案」
說明:
使用VS 2010建置專案出現:
無法將 "obj\x86\Debug\xxx.exe" 複製到 "bin\Debug\xxx.exe"。
重試次數超過 10 次。作業失敗。
無法將檔案 "obj\x86\Debug\xxx.exe" 複製到 "bin\Debug\xxx.exe"。
由於另一個處理序正在使用檔案 'bin\Debug\xxx.exe',所以無法存取該檔案。
做法:
這是因為xxx.exe正在process中,將該開啓的程式關掉與關閉工作管理員-處理程序中的process,若還是不行,先清除專案再至Debug目錄下,將xxx.exe刪除再建置。
使用VS 2010建置專案出現:
無法將 "obj\x86\Debug\xxx.exe" 複製到 "bin\Debug\xxx.exe"。
重試次數超過 10 次。作業失敗。
無法將檔案 "obj\x86\Debug\xxx.exe" 複製到 "bin\Debug\xxx.exe"。
由於另一個處理序正在使用檔案 'bin\Debug\xxx.exe',所以無法存取該檔案。
做法:
這是因為xxx.exe正在process中,將該開啓的程式關掉與關閉工作管理員-處理程序中的process,若還是不行,先清除專案再至Debug目錄下,將xxx.exe刪除再建置。
2015年11月11日 星期三
[.NET] Release建置卻無出現參考的dll檔
說明:使用VS 2010(.NET Framework 4.0),建置程式後,發現參考的dll沒進到Release資料夾內?
原因:因VS 2010加入參考多了內嵌Interop型別,預設為True,導致複製到本機變為False,因此無輸出dll至Release資料夾內,發行時造成某些功能無法正常運作。將內嵌Interop型別改回False,複製到本機即連動為True,重新建置即可。
原因:因VS 2010加入參考多了內嵌Interop型別,預設為True,導致複製到本機變為False,因此無輸出dll至Release資料夾內,發行時造成某些功能無法正常運作。將內嵌Interop型別改回False,複製到本機即連動為True,重新建置即可。
訂閱:
文章 (Atom)