1. 程式人生 > >ProtoBuf_編譯生成DLL錯誤

ProtoBuf_編譯生成DLL錯誤

Unity中匯入DLl後的錯誤日誌:
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 D:\TankPrj\Prj\TankWar1\Assets\Plugins\proto\ProtoSerializer.dll, type System.Runtime.Versioning.TargetFrameworkAttribute
The class System.Runtime.Versioning.TargetFrameworkAttribute could not be loaded, used in ProtoSerializer
Can't find custom attr constructor image: D:\TankPrj\Prj\TankWar1\Assets\Plugins\proto\ProtoSerializer.dll mtoken: 0x0a00041e
Missing method .ctor in assembly D:\TankPrj\Prj\TankWar1\Assets\Plugins\proto\TankModel.dll, type System.Runtime.Versioning.TargetFrameworkAttribute
Can't find custom attr constructor image: D:\TankPrj\Prj\TankWar1\Assets\Plugins\proto\TankModel.dll mtoken: 0x0a000002

解決方法: 開啟mono,右鍵options->General(Build)->Target framework: Mono /.NET 2.0‘
產生原因:unity升級後,mono升級,生成proto協議環境變化