Tuesday, January 28, 2020

error CS0012: The type 'Task<>' is defined in an assembly that is not referenced.

The error CS0012 is typically raised when a required assembly reference is missing. In the context of Unity, this often happens due to plugin conflicts or incorrectly configured references.

If the solution involves removing Unity.Compat.dll and Unity.Tasks.dll from Assets/Parse/Plugins, here's how you can proceed safely:


Steps to Resolve the Issue

  1. Navigate to the Folder:

    • Open your Unity project folder.
    • Go to Assets/Parse/Plugins.
  2. Backup the Files:

    • Before deleting any files, create a backup of Unity.Compat.dll and Unity.Tasks.dll to ensure you can restore them if needed.
    • Copy these files to a different folder outside the Unity project directory.
  3. Delete the Files:

    • Remove Unity.Compat.dll and Unity.Tasks.dll from the Assets/Parse/Plugins directory.
  4. Rebuild the Project:

    • Open Unity.
    • Let Unity re-import the assets.
    • Build your project again to see if the error persists.

If the Error Persists:

  1. Verify Dependencies:

    • Ensure that other plugins or libraries in your project don't rely on Unity.Compat.dll or Unity.Tasks.dll. Check the documentation or the source of the plugin.
  2. Reinstall the Necessary Plugins:

    • If Parse or any other third-party plugin relies on these DLLs, reinstall the plugin from its source to reset dependencies.
  3. Enable Compatibility Mode:

    • Check your Unity project settings:
      • Go to Edit > Project Settings > Player.
      • Under "Other Settings," confirm that the API Compatibility Level is appropriate (e.g., .NET Standard 2.0).
  4. Clean and Rebuild:

    • Delete the Library folder in your Unity project directory (this forces Unity to re-import all assets from scratch).
    • Reopen Unity and rebuild the project.