skip to Main Content

I’ve taken on the so far painful task of trying to port an old, semi-complex, proprietary library from .NET Framework 4.8 to .NET 6 (so basically making the jump from the old "Framework" to "Core"). I used the .NET Upgrade Assistant as a starter and have been trying to get the library to build ever since. After removing 80% of the files from the project in an attempt to find what will still compile, I’ve come across this strange case:

Imports TypeShortcut = System.Collections.Generic.List(Of MyNamespace.Test2)

Public Class Test
    Dim Thing As TypeShortcut
End Class

Public Class Test2

End Class

Obviously the above is a useless simplification from the actual production code. But I’ve added the above exactly into the project as a test. Currently, this code alone is what is preventing my DLL from compiling. If I comment out lines 1 and 4, the project compiles, and if I uncomment them, the compile fails with the error:

error BC30002: Type ‘MyNamespace.Test2’ is not defined.

MyNamespace is the root namespace for the project.

I tried this same code in another upgraded project and it compiles just fine, so I don’t know if you’ll be able to reproduce this. (The other project compiles to an executable instead of a DLL. Not sure if that makes a difference.)

I’ve already tried:

  • Closing and reopening Visual Studio
  • Clean then Rebuild on the project
  • Deleting the bin and obj folders

What do you think could be wrong with the project that is preventing this from compiling like it should? What else can I try?

2

Answers


  1. Chosen as BEST ANSWER

    After messing around for a while, I eventually just decided to do things the "hard" way. I made a brand new .NET 6 project, manually copied over all the settings I could find, manually re-added all the needed references/dependencies/packages, and then manually copied all the code and resource files. And everything works.

    I don't know what the Upgrade Assistant did to that project that screwed it up, but I no longer need to try and figure it out.

    (I still have the messed up project for now, though. So if anyone comes up with an actual answer to the question as written, getting the Upgrade Assistant project to work properly, I'll still give proper credit.)


  2. This does not look like a .net 6 migration, because it also does not compile with the old .NET Framework.

    Try adding the Namespace around your class definition or removing the namespace prefix on your first line. For example, this compiles for me:

    Imports TypeShortcut = System.Collections.Generic.List(Of MyNamespace.Test2)
    
    Namespace MyNamespace
    
        Public Class Test
            Dim Thing As TypeShortcut
        End Class
    
        Public Class Test2
    
        End Class
    
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search