Search code examples
vb.netvb6windows-forms-designervb6-migrationmscorlib

"Could not resolve mscorlib ... .NETFramework,Version=v2.0" in VS2015 from VB6


My question is similar to others, but my particular nuance of this problem doesn't appear to have an answer I can find on here so far, so here goes. (edits in italics)

Our company has a deployed application written in VB6. Since VB6 development is no longer officially supported in Windows, our company made the decision to port our VB6 application to VB.NET.

(Prior to this edit, I had mentioned that the project was converted to VB.NET using VS 2015. This was incorrect, I discovered that my coworker had actually performed the conversion using VS 2008, and I was working on the 2008 project in 2015.)

So we are now working with the VB.NET conversion in VS2015. As many of us know, the VS 2008 converter does an incomplete job porting VB6 code to VB.NET code so there are many, many errors to sort through (as of this writing, all compile errors are fixed). In particular, though, I'm trying to open the various forms for the project in the Designer so I can see and work with them. The designer specifically is reporting the error:

Could not resolve mscorlib for target framework '.NETFramework,Version=v2.0'. This can happen if the target framework is not installed or if the framework moniker is incorrectly formatted.

I saw some mention of a 256 character limit on dependency paths. This dependency is met in my case. I have also confirmed that .NET Framework 2.0 is installed and active in my instance of Windows. I have seen the recommendation to upgrade the .NET Framework version as well, which was successful in itself but did not resolve this mscorlib issue.

Full call stack for this error follows:

at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse..ctor(IDesignTimeAssemblyLoader assemblyLoader, IVsDesignTimeAssemblyResolution projectAssemblyResolution, IVsSmartOpenScope dispenser)
at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkUniverse.GetUniverse(IDesignTimeAssemblyLoader assemblyLoader, IVsDesignTimeAssemblyResolution projectAssemblyResolution, IVsSmartOpenScope dispenser)
at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkProvider..ctor(IVsDesignTimeAssemblyResolution assemblyResolution, IDesignTimeAssemblyLoader assemblyLoader, TypeDescriptionProvider parentProvider, IVsSmartOpenScope openScope)
at Microsoft.VisualStudio.Design.VsTargetFrameworkProviderService.get_TargetFrameworkProvider()
at Microsoft.VisualStudio.Design.VsTargetFrameworkProviderService.GetProvider(Type type)
at System.ComponentModel.Design.Serialization.DesignerSerializationManager.GetType(String typeName)
at System.ComponentModel.Design.Serialization.DesignerSerializationManager.System.ComponentModel.Design.Serialization.IDesignerSerializationManager.GetType(String typeName)
at System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, CodeTypeDeclaration declaration)
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.DeferredLoadHandler.Microsoft.VisualStudio.TextManager.Interop.IVsTextBufferDataEvents.OnLoadCompleted(Int32 fReload) 

How can I gain the ability to view my project in the Designer?


Solution

  • As far as I know, opening VB6 files in VB.NET will not work. You will have to make modifications in Visual Studio 6.0 or re-write the application in VB.NET/C#.

    Older versions of Visual Studio (until 2008) had some converters but they never really worked as expected.

    You can take a look at Visual Basic Tools for Visual Studio, it "allows to work with classic VB workspaces and projects within Visual Studio.", this will allow you to modify the VB6 project in a newer version of Visual Studio but the code will remain VB6.

    Regarding your exact issue, others have reported that the following worked for them:

    1. Remove and add back project references that have warnings.
    2. Rebuild the project
    3. Remove and add back Microsoft.Office.Core

    Good luck!