Search Unity

Visual Studio can't find assembly while Unity doesn't complain when using assembly definition

Discussion in 'Editor & General Support' started by Amplify_Paulo, May 12, 2020.

  1. Amplify_Paulo

    Amplify_Paulo

    Joined:
    Jul 13, 2017
    Posts:
    297
    Hi all!

    Trying to use assembly definition files here and got to this case that I can't seem to find my way around it.

    If I have a parent class that belongs to a specific assembly but still remains public and then I create a child of that class outside of that assembly unity doesn't complain and works as expected (?) but visual studio can no longer reference that parent class and shows an error. This a direct byproduct of using the asmdef file.

    Also, I do know I can create a an asmdef reference file that will make the child class belong to the same assembly and VS works correctly in that case, however this is not what I'm looking for. And in theory and in practice I'm able to have the child class outside of the main assembly in unity. But visual studio still throws an error.

    How can I solve this?
    Unity 2019.3.12f, Visual Studio 2019 with all latest updates and with unity tools addon

    Unity_vgrs7srnYG.png

    devenv_NQLmcNf6NH.png
    Unity_wXbWo6t6ZE.png
     
  2. drallcom3

    drallcom3

    Joined:
    Feb 12, 2017
    Posts:
    165
    I have the same problem. Happens with 2019.3, 2020.1 and 2020.2.
    Doesn't really matter which setup I use. Some, but for an unknown reason not all, definitions aren't recognized in VS.
    I already tried deleting all .csproj, .sln, as well as the Library, .vs and obj folders.

    There's already a thread https://forum.unity.com/threads/ass...ken-with-visual-studio-in-2019-3-12f1.882967/ and it does have some solutions.
    Terrible fix that actually works: https://forum.unity.com/threads/2019-3-12f1-build-errors.880312/#post-5789368
     
  3. Amplify_Paulo

    Amplify_Paulo

    Joined:
    Jul 13, 2017
    Posts:
    297
    oh uau, I didn't found those threads in my search, thank you
     
  4. StickyKevin

    StickyKevin

    Joined:
    Jul 1, 2020
    Posts:
    22
    I ran into this again today with Unity's assemblies in version 2020.3.34.f1 in Visual Studio Community 2022.
    I have resolved the issue in VS by right clicking the solution in the solution explorer and clicking Load All Solutions.
    I have generated csproj. files for Embedded-, Local- and Registry packages, if that has anything to do with it.
     
    daivq_unity likes this.