'class' is missing the class attribute 'ExtensionOfNativeClass'!

Hi,
I’m trying to create a mobile game using sqlite as a database. To do this, I’m using SQLite4Unity3d (github here) with an existing database. His sample project works perfectly when I try to run it and when I build it on a phone. So I adapted his project to mine by creating a Note class like his Person class but when I go back to the unit editor an error appears, like below, even though the methods using this class work.

8206842--1071075--upload_2022-6-15_10-10-43.png

Searching the web it looked like another class called Note was also being used, which was true (and was a monobehavior) but I removed it and the error still appears. The list of my scripts in my project with Note in their name listed here:

8206842--1071108--upload_2022-6-15_10-34-12.png

I guess residuals from the old class could be a problem but I don’t know how to know if there is some and so how to find and remove them.

Here is my Note.cs :

using SQLite4Unity3d;

public class Note
{
    [PrimaryKey, AutoIncrement]
    public int Id { get; set; }
    public int IdPartition { get; set; }
    public double Midi { get; set; }
    public double Mesure { get; set; }
    public int Ticks { get; set; }
    public int Duration { get; set; }
    public int Time { get; set; }
}

Here is the Person class from which I am inspired

using SQLite4Unity3d;

public class Person  {

    [PrimaryKey, AutoIncrement]
    public int Id { get; set; }
    public string Name { get; set; }
    public string Surname { get; set; }
    public int Age { get; set; }

    public override string ToString ()
    {
        return string.Format ("[Person: Id={0}, Name={1},  Surname={2}, Age={3}]", Id, Name, Surname, Age);
    }
}

It’s likely leftover in the “Library” folder. You can delete that folder and it’ll be regenerated although depending on the size of your project, it might take some time. Obviously you’ll need to ensure you’ve not got the project loaded at the time.

Just tried but still not the solution.
Maybe in fact there are some prefabs/scripts using the old Note.cs because they have the same name, but I don’t know if there is a way to find them easily…
I will try by changing the name

2 Likes

Update : Just tried by changing the name to NoteDB.cs but the error is still here when I build in .aab

SOLUTION :

Some of my game objects were having the old script.

To find them easily, you can right click on your script and click on “find references in the scene”. :slight_smile:

25 Likes

Another solution is (almost what @MelvMay mentioned) the following:

  • Close Unity Editor.
  • Remove the Library/ folder.
  • Remove meta files for the broken classes.
  • Open Unity Editor (meta with new hash will be generated).

The solution does not require any scene or prefab modification :slight_smile:

1 Like

Assets > Reimport All worked for me

Had the same error and it turned out that it’s the old missing script that was causing it. Removing it fixed the issue.

9178898--1278311--upload_2023-7-28_23-38-1.png

7 Likes

This was my issue! Thank you!

1 Like

This can also happen if you add a script to a gameobject and then (for whatever reason) that script no longer inherits from MonoBehavior. Just redefine your class as

public class MYCLASS : MonoBehaviour {

Happened to me when consolidating virtual classes with children and screwing up the class definition. good luck out there devs

6 Likes

The cause of the problem is the presence of both system.collections and system Namespaces. Try creating the required class in other script and give a reference here.

thanks this was hard to catch

Wow! Thanks @spilat12