3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Unityで自作DLLライブラリをインポートしたらエラーが出たとき

Posted at

はじめに

環境
  • Win 8.1
  • Unity5.3.5p5
  • Visual Studio Community 2013

C#でDLLを作成しUnityにインポートしたところ以下のようなエラーが出ました。

Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.

なんか使えないクラスとかを使おうとしているかロードできないって言われました。
しかし、DLL内にはUnityでも動くようなコードしか書いていない・・はて?と思い少し調べました。
ggっても解決しなかったので、私の場合の解決方法を備忘録として記載します。同様の人がいれば幸い

色々検索した結果

こちらの記事で同様のエラーが出ている様子
たしかに私のDLL内にも同様の「AssemblyInfo.cs」というファイルが自動で入っていたので消してみた

が、しかし未だエラー消えず。。

Unityの公式QAを見たらこんなもの
この方はどうやら同様のエラーの様子。色々回答を見ているとどうやら.NETのverの問題とのこと

解決方法

しかし、DLLのプロジェクトを見てもver3.5までのUnityでも動くコードしか書いてないし・・・と思ったけど、よく考えたらVisualStudioのでは4.0以上の設定でコンパイルしているはずなのでエラー出るのは当たり前だった

なので、DLL側のプロジェクト設定を変更したら解決した
具体的には

[プロジェクト名].csproj 

というファイルがプロジェクト直下にあるはずなのでそれを開く
すると"TargetFrameworkVersion"という項目が"v4.5"になっていた
それを画像のように"v3.5"に変更すれば終わり

updateJpg.jpg

3
4
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
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?