###前提・実現したいこと
Visual studio2015を用いて
c#で作成したクラスライブラリ(DLL)を作成して
Unityで読み込み使用したいのですが
下記問題が発生して先に進めません
解決方法をご存知の方がいらっしゃいましたら、修正方法をご教授ください
よろしくお願いいたします。
###発生している問題・エラーメッセージ
Unhandled Exception: System.Reflection.ReflectionTypeLoadException:The classes in the module cannot be loaded.
at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (bool)
at System.Reflection.Assembly.GetTypes () [0x00000] in <filename unknown>:0
at Mono.CSharp.RootNamespace.ComputeNamespaces (System.Reflection.Assembly assembly, System.Type extensionType) [0x00000] in <filename unknown>:0
at Mono.CSharp.RootNamespace.ComputeNamespace (Mono.CSharp.CompilerContext ctx, System.Type extensionType) [0x00000] in <filename unknown>:0
at Mono.CSharp.GlobalRootNamespace.ComputeNamespaces (Mono.CSharp.CompilerContext ctx) [0x00000] in <filename unknown>:0
at Mono.CSharp.Driver.LoadReferences () [0x00000] in <filename unknown>:0
at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0
at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0
Missing method .ctor in assembly C:\Users\user\Documents\sample01 csvyomikomi\Assets\ClassLibrary8.dll, type System.Runtime.Versioning.TargetFrameworkAttribute
The class System.Runtime.Versioning.TargetFrameworkAttribute could not be loaded, used in ClassLibrary8
Can't find custom attr constructor image: C:\Users\user\Documents\sample01 csvyomikomi\Assets\ClassLibrary8.dll mtoken: 0x0a00000e
###該当のソースコード
下記手順で行いました
Ⅰ・visual studio2015でDLLファイルを作成
【ソース】
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DLLTEST2
{
public class Class1
{
public static int Hoge()
{
return 114514;
}
}
}
上記ソースコードをビルドしてDLLファイルを作成しました。
※ビルドする前に、Solution Explorer→References→Add Referenceから
UnityEditor.dllとUnityEngine.dllを追加しています。
Ⅱ・Unityを立ち上げ
Project→Assetsに、Ⅰで作成したDLLをドラッグ&ドロップして追加しました。
その後、Unityで下記ソースを作成し、実行しました。
【ソース】
using UnityEngine;
using System.Collections;
using DLLTEST2;
public class Test : MonoBehaviour {
// Use this for initialization void Start () { Debug.Log(Class1.Hoge()); }
}
この手順で実行した所
シーン上にAll compiler errors have to be fixed before you can enter playmode というエラーが発生し
コンソールには
Unhandled Exception: System.Reflection.ReflectionTypeLoadException:
The classes in the module cannot be loaded.
というエラーメッセージが表示、現在実行できていません
###試したこと
###補足情報
あなたの回答
tips
プレビュー