Designer can't load form - "could not load type ...from mscorlib ....due to value type mismatch"

Hi,

I'm getting the classic pink error banner when trying to view most of the forms in my solution in VS 2005. Everything was working OK up to yesterday when installed SQL Server 2005 SP1 (which installed a new copy of the .NET framework) and also installed Team Explorer.

Tried re-loading everything from source control etc but no solution as yet.

These forms were originally written in VS2003 so have the forms designer code embedded. A couple of forms added in VS2005 don't exhibit the problem.

Any solutions or workrounds gratefully accepted !

Typical messages in full

Could not load type 'System.Runtime.InteropServices.ClassInterfaceType' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' due to value type mismatch.

variation

Could not load type 'System.Byte' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' because the format is invalid.

Cheers




Answer this question

Designer can't load form - "could not load type ...from mscorlib ....due to value type mismatch"

  • buladbanaw

    I watched the video and what was not in it is how we fix/avoid WSOD (D <> Darn, D = big pain in the ***).

    Question Are hotfixes 912019 and 921019 included in SP1 or should we install them Does 921019 supercede 912019 Are they worth installing

    I tried to ask the above question through the $99 email support option. It took my credit card but when I stopped it from reading my Outlook address book it locked up (it wanted to gather information about my PC).

    I have put in days trying to understand WSOD (days I should have writing code). There must be a dozen popular work arounds from turning indexing off on the directories ( ) to deleting the obj and and bin directories. Sometimes they work but usually not. A couple of web sites say to debug the devenv.exe with another instance of devenv.exe but I have not been able to get to work and anyway I want to write code not debug Visual Studio.

    I have tried Microsoft Developer Support (Project - SRX061129602366). I sent them the project. They acknowledged the bug and offered some suggestions but if I fix WSOD it soon comes back because of another/new problem.

    One thing I would like to know is why so many people are fighting WSOD and a lot are not Is it coding style or what I always get it when my winform gets a lot of controls on it.

    Is anyone trying to fix this or you just making videos

    Incase you can not tell I am frustrated and pissed off at Microsoft.

    static void Main(string[] args)

    {

    int n = 0;

    bool WSOD = true;

    while ((n++ < 100000) && (WSOD))

    {

    Console.WriteLine(" WSOD Rant {0}", n);

    }

    if (WSOD == true)

    {

    Console.WriteLine(" Switch back to Delphi!!!!");

    }

    }


  • Tim Mercer

    Richard... Thank you. I had the following error when deploying the Adventureworks Analysis Services Tutorial:

    Errors in the high-level relational engine. The following exception occurred while an operation was being performed on a data source view: Could not load type 'System.Data.Keywords' from assembly 'System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' due to value type mismatch..
    I performed a repair as you suggested and was able to deploy the cube.

  • Batisse

    I'm having the same problem since installing the VS2005 SP1 patch....

  • GovardhanReddy

    Thanks for getting back to me Deborah.

    I have tried closing all forms and rebuilding solution but it did not make any difference.

    Yes the forms which do not display in the form designer inherit from system.windows.forms.form

    If I look at mscorlib in the VS Object Browser it tells me it is located at

    Assembly mscorlib

    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll

    Cheers

    Richard



  • Luis Esteban Valencia Mu&amp;#241;oz

    Well I have sorted it. I went to add/delete programs and took the repair option on .NET Framework 2.

    I don't know if it was the SQL 2005 SP1 that caused it but I suspect it was as I had problems installing that particular service pack. I suspect it left things in a bad state.

    Hope this helps someone else if they ahve the same problem.

    Cheers

    R



  • sooline

    Just to confirm previous message. I had exactly the same error and cause: failed installation of Visual Studio 2008 Beta 2.

    Repairing .NET Framework 2.0 worked for me too.


  • Surezsu

    If you want to give feedback on "the classic pink error banner", Brad Abrams has posted a preview of improvements over on his blog:

    http://blogs.msdn.com/brada/archive/2007/01/16/what-is-next-for-winforms-wsod-in-orcas.aspx

    Head over, watch the video, and let us know what you think!

    Thanks,

    Windows Forms Team



  • Michal Konecny

    I figured that this problem was caused by trying to install Visual Studio 2008. I removed the .net framework 3 and SQL server. I can't seem to be able to repair the .NET framework 2.

    I get a message saying:

    Setup Cannot continue because this version of the .NET Framework is incompatible with a previousely installed one.

    Any suggestions

  • SOTY_Programmer

    Same problem (after sp1), same fix...tnks at least i've solved the problem in only a fast google seachSmile


  • GertB

    I had the same error:

    Could not load type 'System.Byte' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' because the format is invalid.

    Google only gave me two pages with this exact error.

    Doing the repair option on the .NET Framework 2.0 worked wonders! Thank you so much, you made my day!

    For me, I must have killed it when I tried (and failed) to install Visual Studio 2008 Beta 2.


  • ChitownDotNet

    I have gotten something similar from time to time.

    What normally takes care of it for me is to close all of the forms and then rebuild the solution.

    BTW - do these forms inherit from a base form class


  • Designer can't load form - "could not load type ...from mscorlib ....due to value type mismatch"