12月 012014
 
Pocket

問題

  1. .NET 4 アプリケーションを作る
  2. Microsoft.Net.Http や Microsoft.Bcl.Async を参照する
  3. MsBuild /t:Publish する
  4. 配置した ClickOnce アプリを起動する
  5. アプリは死ぬ

解決策

  1. 参照してるアセンブリファイルをプロジェクトにコピー (公式手順的にはリンクとしてコピーだが物理コピーでも可っぽい)
  2. 「出力ディレクトリにコピー」を「常にコピーする」に変更
  3. 発行!

NuGet で更新する度にコピーし直さないといけないけど……

Microsoft.Net.Http

Issue 8

Symptom

ClickOnce applications targeting .NET Framework 4.0 that reference the Microsoft.Net.Http package may experience a TypeLoadException or other errors after being installed.

Resolution

This occurs because ClickOnce fails to deploy certain required assemblies. As a workaround, do the following:

Right-click on the project and choose Add Existing Item
Browse to the HttpClient net40 package folder
In the File name text box enter *.*
Holding CTRL, select System.Net.Http.dll and System.Net.Http.Primitives.dll
Click the down-arrow next to the Add button and choose Add as Link
In Solution Explorer, holding CTRL select System.Net.Http.dll and System.Net.Http.WebRequest.dll
Right-click the selection, choose Properties and change Copy to Output Directory to Copy always
Republish

引用元:http://blogs.msdn.com/b/bclteam/p/httpclient.aspx

System.Net.Http.Primitives.dll とか System.Net.Http.WebRequest.dll のことも書いてあるけど、 System.Net.Http.dll だけでOKだった。
むしろ System.Net.Http.Primitives.dll をコピーしてると、起動時に「もうあるよ!」的なエラーで死んだ。
そもそも手順的に Primitives をコピーしてるのになぜ WebRequest が出てくるのか……怪しげな説明。。

Microsoft.Bcl / Microsoft.Bcl.Async

Issue 9

Symptom

ClickOnce applications targeting .NET Framework 4.0 that reference the Microsoft.Bcl or Microsoft.Bcl.Async packages may experience a TypeLoadException or other errors after being installed.

Resolution

This occurs because ClickOnce fails to deploy certain required assemblies. As a workaround, do the following:

Right-click on the project and choose Add Existing Item
Browse to the Microsoft.Bcl net40 package folder
In the File name text box enter *.*
Holding CTRL, select System.Runtime.dll and System.Threading.Tasks.dll
Click the down-arrow next to the Add button and choose Add as Link
In Solution Explorer, holding CTRL select System.Runtime.dll and System.Threading.Taks.dll
Right-click the selection, choose Properties and change Copy to Output Directory to Copy always
Republish

引用元:http://blogs.msdn.com/b/bclteam/p/asynctargetingpackkb.aspx

 Leave a Reply