LoginSignup
6
6

More than 5 years have passed since last update.

[Xamarin.Forms]Shared ProjectでカスタムコントロールのAssemblyが見つからない時の対処法

Last updated at Posted at 2015-01-25

Xamarin.FormsのPCLプロジェクトからSharedプロジェクトに乗り換えたら少しハマったのでメモ。

問題

共有プロジェクトで作ったカスタムコントロールをXAMLで参照する際、xmlns:local="clr-namespace:MyApplication;assembly=MyApplication"のように名前空間を追加すると思います。これをそのまま実行すると...

System.IO.FileNotFoundException has been thrown
Could not load file or assembly 'MyApplication' or one of its dependencies. The system cannot find the file specified.

こんな例外が出ます。
これは、PCLプロジェクトと違って共有プロジェクトのAssemblyが作られないことが原因です。

対処

プロジェクトのプロパティから、全プラットフォームの出力アセンブリ名を同じにします。
プロジェクト名と同様に付加されている ".iOS" や ".Droid" の部分を削除しましょう。(iOSプロジェクトでは実機、シミュレータの両方の設定があるので忘れないように注意)

AssemblyName.jpg

こんな感じ。

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6