Using Cecil in Unity

I am trying to use Cecil, a library written by Jb Evain to generate and inspect programs and libraries in the ECMA CIL format. See link : Mono.Cecil | Mono

 using System;
 using UnityEditor;
 using Mono.Cecil;
 
 public class TestCecil
 {
	 [MenuItem("Assets/TestMenu")]
	 protected static void LookForUnusedClasses(){
		 
	 }
 }

But I have the following error :

The type or namespace name Cecil does not exist in the namespace Mono. Are you missing an assembly reference?

Not sure if this changes anything, but I tried switching from .Net 2.0 Subset to regular, but I still get the same errors. Thanks in Advance.

2 Answers

2

Try to install Unity with “Windows Store IL2CPP Scripting Backend” selected in Unity install.

That should help. @nliao

Well do you have that library actually inside your project? If not you have to copy the DLL into your Assets folder. Keep in mind that the mono framework in Unity is not an actual globally available framework as it’s used as embedded environment inside Unity. Only some core files are automatically included. Any other files need to be copied manually.