Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2015 Add Class, Error: "object already exists"

Other similar but to my knowledge non-related questions:

  • A file or folder with the name '' already exists Visual Studio 2012
  • ATL simple object wizard - "Object Xxx already exists" error

  • The error:
    I try to add a simple class enter image description here and then proceed to the wizard where I get the following Error]2: enter image description here "Object already exists".
    I can't add the class "MainGame" (and a few other names) to any project, not even if I create a new project

    How to recreate said bug/error:
    The error occured when I deleted a Release folder I'd accidentally copied over from a project in another solution. All now non-functional class names are derived from the object files within that Release folder.

    Solution:
    I have no solution.

    My questions are:
    Have anyone else had this or a similar issue?
    If so, have you solved it and what is your solution?

    I am open to all suggestions and while this 'bug' isn't making programming impossible it is quite annoying not being able to use frequently used class names.

    like image 326
    Bjartskular Avatar asked Nov 15 '16 21:11

    Bjartskular


    3 Answers

    Yeah, also saw that.

    I think I have created a C++ class, decided I don’t like it, reverted changes using github app. But the name was good, so I tried creating same class again. Saw the exact same error as you’re having.

    The name polluted the sqlite database. And because I had that VC.db in my .gitignore, git hasn't reverted that.

    To fix, quit visual studio, delete the file $(SolutionName).VC.db in your $(SolutionDir) folder, restart visual studio, clean and rebuild your project[s].

    Update: Modern versions of Visual Studio usually keep these SQLite databases inside .vs folder under $(SolutionDir).

    like image 83
    Soonts Avatar answered Nov 11 '22 00:11

    Soonts


    Seems like VS caching issue. I too faced this issue and your solution did not work for me either.

    What I did is add a Class with different name lets say MainGame1 and then it allowed me to add. Then I just renamed the Class name, CPP and header file name to my like.

    like image 1
    Bit_Pulse Avatar answered Nov 10 '22 23:11

    Bit_Pulse


    Manually create example.h and example.cpp in Solution directory then:

    Add -> Existing Item... -> add created file to your project.

    This trick work for me after clean $(SolutionName).VC.db file.

    like image 1
    mohammad madani Avatar answered Nov 11 '22 00:11

    mohammad madani