Friday, April 30, 2010

VS2010 "cannot create the window"

I installed the release-to-market (RTM) version of Visual Studio 2010 and it worked well for a few days and then suddenly it started giving me a "cannot create the window" error and refused to start.

I did a whole bunch of searching and discovered that there were some incompatibilities with Office 2010 beta (an incompatible DLL) that was causing most of the problems. Not in my case though because I'd never installed Office 2010. If, however, you are reading this and you have installed a version of Office 2010 then you might want to search further as that might be your problem.

I contacted the developers at Microsoft and they were outstanding in the help that they provided me. I downloaded a debugger and created some memory dumps of what was happening in VS2010 when it started and sent them off to Microsoft. They isolated that the problem was happening when the machine.config file was being loaded. I know that I had edited my machine.config and so I became suspicious of my edit.

A quick aside about machine.config's. On a 32-bit operating system with .NET 2 installed there's only one machine.config and that usually lives here:

C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG

If you have installed VS2010 then that means that you have also installed .NET 4 so there's another machine.config for .NET 4 and you can find that here:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config
(On my machine this is the one that VS2010 is using even though I'm running Windows 7 x64.)

If you have a 64-bit OS then you have 64-bit versions of these machine.config's as well taking the total to four. These can be found here:

C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config

(I don't know why one is in capitals and the other in proper case.)

An analysis of my machine.config's (all 4 of them) showed that I have incorrectly edited 2 of them. I had added a new section to the machine.config but had failed to add that section name to the sectionGroup. So I was missing this part of the machine.config:

<sectionGroup name="myNewSectionGroupName" ... > <section ...> </sectionGroup>

Which goes inside the <configSections> ... </configSections> part of the file.

In the end it was a PIBKAC* and not a VS2010 bug.

*PIBKAC = Problem Is Between Keyboard And Chair

 

6 comments:

  1. Thanks - machine.config edits were my problem too. The poor error message is a VS2010 bug even if silly people editing system files is a PIBKAC :)

    ReplyDelete
  2. Thank you! that solved my problem. I had modified processmodel tag and there was a spacing missing between attritbutes.
    cheers,

    ReplyDelete
  3. Thank you !!!!!
    I edited the machine.config and other pages of a project, when my son for four years, edited and saved all closed!
    thereafter began my suffering!
    are two in the morning and thank you again tomorrow I can work on the project!

    ReplyDelete
  4. Thy this link, That may help you delphintipz.blogspot.com/.../how-to-recover-

    ReplyDelete
  5. Frederik InghelbrechtMarch 27, 2012 at 10:43 AM

    I tried the solution above and then I noticed that I couldn't open the machine.config with notepad. Only If I ran notepad 'as administrator' I was able to edit.
    If I startup Visual studio 2010 in normal mode I still get "cannot create the window" error.
    If I run Visual studio 2010 as administrator, Everything works fine.
    (how to do: right click and select 'rus as administrator')

    ReplyDelete
  6. I just installed VS 2010 professional and tried to open the dev env. I did not edit any config files. Just tried to open the VS 2010 after successful installation. I GOT "Cannot create the window" error.
    Am I doing any error???

    ReplyDelete