Visual Studio - parameter instance with value null (and other design errors) when opening XSD files How to fix the "Value cannot be null. Parameter name: instance" error when opening XSD files in design mode with Visual Studio 2017 or 2019

Visual Studio - parameter instance with value null (and other design errors) when opening XSD files

If you've stumbled upon this post it most likely means you're having issues while trying to open XSD files from Visual Studio 2017 or 2019. More specifically, this problem often happens when you try to open a .xsd file of a rather old project, originally created using the ASP.NET Framework 2.0, 3.5 or so on and then upgraded to ASP.NET 4.x later on.

The error message presented by the Visual Studio GUI is the following:

Value cannot be null. Parameter name: instance

And here's the stacktrace:

Hide Call Stack at System.ComponentModel.TypeDescriptor.AddAttributes(Object instance, Attribute[] attributes) at Microsoft.VisualStudio.Design.VSDesignSurface.CreateDesigner(IComponent component, Boolean rootDesigner) at System.ComponentModel.Design.DesignerHost.AddToContainerPostProcess(IComponent component, String name, IContainer containerToAddTo) at System.ComponentModel.Design.DesignerHost.PerformAdd(IComponent component, String name) at System.ComponentModel.Design.DesignerHost.Add(IComponent component, String name) at System.ComponentModel.Container.Add(IComponent component) at Microsoft.VSDesigner.DataSource.Designer.DataSourceDesignerLoader.HandleLoad(IDesignerSerializationManager serializationManager) at Microsoft.VSDesigner.DesignerFramework.BaseDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager) at Microsoft.VSDesigner.DesignerFramework.BaseDesignerLoader.Microsoft.VisualStudio.TextManager.Interop.IVsTextBufferDataEvents.OnLoadCompleted(Int32 fReload)
This seems to be .net 3.5 specific as I opened another project that's 4.0 and its .xsd opened in designer fine.

Here's a screenshot showing the error, as shown by the Visual Studio xsd design view/mode:

Visual Studio - parameter instance with value null (and other design errors) when opening XSD files

UPDATE: depending on Visual Studio and .NET Framework, some times the error message can be slightly different, such as:

There is no designer for the class Microsoft.VSDesigner.DataSource.DesignDataSource.

Luckily enough, the workaround is still the same.

The Workaround

At the time of writing (July 2019) there are at least two open issues created to address this problem on the Visual Studio Developer Community website:

Despite these feedbacks, there are no official answers - or fixes - released by Microsoft so far.

Luckily enough I was able to find a workaround by mixing two different suggestions taken from two treads on MS Development Network and StackOverflow. The workaround I found works that way:

  • Open the Project (or Website) Property Page.
  • Locate the section where you can choose the .NET Framework version (Start Options -> Build for most project types).
  • If your project is using a .NET Framework lower than 4.7.2, set it to 4.7.2 (in case you don't have it installed, you might have to download it and restart Visual Studio afterwards).
  • If your project is using the .NET Framework 4.7.2, downgrade it to 4.6.1 (again, if you don't have it download it and restart Visual Studio).

This should permanently fix your problem and let you open the XSD files in design mode.

 

About Ryan

IT Project Manager, Web Interface Architect and Lead Developer for many high-traffic web sites & services hosted in Italy and Europe. Since 2010 it's also a lead designer for many App and games for Android, iOS and Windows Phone mobile devices for a number of italian companies. Microsoft MVP for Development Technologies since 2018.

View all posts by Ryan

3 Comments on “Visual Studio - parameter instance with value null (and other design errors) when opening XSD files How to fix the "Value cannot be null. Parameter name: instance" error when opening XSD files in design mode with Visual Studio 2017 or 2019

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

This site uses Akismet to reduce spam. Learn how your comment data is processed.