Rick Strahl's Weblog  

Wind, waves, code and everything in between...
.NET • C# • Markdown • WPF • All Things Web
Contact   •   Articles   •   Products   •   Support   •   Advertise
Sponsored by:
Markdown Monster - The Markdown Editor for Windows

LINQ to SQL DBML fails to build or open

On this page:

Arrgh. Today I got back to a LINQ to SQL app that’s been sitting idle for some time. It’s a demo app and as I started the app up and compiled the solution I got:

Error 1 Build failed due to validation errors in C:\projects2008\TimeTrakker\TimeTrakkerBusiness\model\TimeTrakker.dbml. Open the file and resolve the issues in the Error List, then try rebuilding the project. C:\projects2008\TimeTrakker\TimeTrakkerBusiness\model\TimeTrakker.dbml

Well, I opened the file and looked at the error list – according to the error list it’s a parsing error at a / with no line number and not even a filename. Swell.

I remember odd parser behavior when upgrading between the beta version and the final release. I think the change at the time was an encoding change from UTF-16 to UTF-8 or something along those lines that caused the document not to be readable. But it turns out that wasn’t the problem. I checked encoding saved the file and validated the XML – no problem there.

I then opened another project with another Linq to SQL model and it too fails with the same error.

So this is a more serious issue. At this point I turned to Google to search and sure enough this has been found on a few occasions (like this post from Michael James).

As Michael points out the fix is to reset the Visual Studio Packages. Apparently at one of the many times that VS starts and complains about a package load failure – you know those failures where you usually have no idea what you’re consenting to exactly :-} - I must have unknowingly unloaded the DBML parsing package.

The fix is to run devenv /ResetSkipPkgs:


This fires up Visual Studio and reloads all packages that were previously skipped.

What’s really odd about this is that this is a fairly new machine that has been running solidly and so I don’t actually remember any package load errors. I sure hope that this problem doesn’t show up like this out of the box after an install of VS 2008 SP1? Anybody seen this on a ‘clean’ machine?

Thankfully we have the Internet to search for stuff like this and I found Michael’s post in short order. This is also a good reminder – at least to me – that quite a few Visual Studio problems can be solved by the various reset flags available via the devenv command line switches. Just a few days ago I got my toolbox mangled by a bad component install that actually cause VS to crash on startup. I was able to get into VS in Safemode and reset the toolbox that way.

Imagine having to deal with this sort of issue without the resources of shared knowledge.  So much time is wasted on crap like this that shouldn’t be happening in the first place, and which reduces the productivity that a powerful IDE like VS provides. I’d really hate to total up the hours I spent tracking down some obscure Visual Studio bug or behavior in a year… I’m sure it totals out to a full week of billable time.

Posted in Visual Studio  LINQ  

The Voices of Reason


Kevin Davis
October 10, 2008

# re: LINQ to SQL DBML fails to build or open

Dude, I totally relate to your issue with VS. I have to run VS 2005 for a couple remaining legacy SharePoint projects and have many issues with templates and more seriously, one of my projects could and would not resolve any of my references (even the System, System.Web...) I tried updating the paths, in the properties, removing and readding, I worked on this for many, many days, with no luck, I asked one of your contemporary .NET gurus, Peter Bromberg. Then one day out of the blue, they resolved. I changed nothing, did nothing, see nothing. Like you I wasted many hours working on the IDE versus developing solutions.

Look forward to hearing your talks in Vegas this November. I live on Oahu and met you briefly last year at the last Dev Connections.

BTW, you need to see Styx in concert tonight in Maui, I saw them yesterday on Oahu, they kicked butt!



Steve from Pleasant Hill
October 10, 2008

# re: LINQ to SQL DBML fails to build or open

Re: Styx... I'm guessing Rick is WAY too hard-core of a rocker to go hear that stuff...

October 10, 2008

# re: LINQ to SQL DBML fails to build or open

Styx is not rock?? Since when? I have followed them since the 70s, I got a chance to see them in 77. They rocked then and they rocked last night!



October 24, 2008

# re: LINQ to SQL DBML fails to build or open

One easy answer is to dump the pathetic MS offering and use something better with a decent interface like llblgen pro. Admittedly I've not used the linq version of llblgen yet it but it is available and I read Frans's blog whilst he was creating the linq extensions and it sounds like there are far too many limitations with the MS implementation!

If you've not had a look yet it's well worth it and I pretty much guarantee it will save you time!

(Fanboy alert!! ;) )

Rick Strahl
October 24, 2008

# re: LINQ to SQL DBML fails to build or open

@Caveman - I've looked at llBlGen and like it. It's definitely a more complete and well thought out solution than anything Microsoft has or ever has offered, not even to mention that it works more along the lines that I think about data access.

Unfortunately for many of the things that I do it's not appropriate because of public domain redistribution issues so I'm stuck with using either what comes in the box or using an OSS.

February 19, 2009

# re: LINQ to SQL DBML fails to build or open

This doesn't appear to resolve the issue all the time. Using 2008 SP1 once opening the dbml file the Error: And Item name 'X' already exists. Please choose a different name. If you try to rename the method to anything else which would be unique as well the editor returns the same error. Undoing checkout on the dbml file from TFS then rebuilding while the project is still checked out will allow the build to succeed, but as soon as undo on the project or check in on the project is done the build fails again. Doing a TFS compare on the project shows no changes between the projects or the dbml files as well.

March 09, 2009

# re: LINQ to SQL DBML fails to build or open

Nice one, sorted my issue.

Jason Kergosien
May 14, 2009

# re: LINQ to SQL DBML fails to build or open


Thank you for this. You probably saved me 2-4 hours of troubleshooting.


June 03, 2009

# re: LINQ to SQL DBML fails to build or open

I'm finding that I need to close and restart Visual Studio to "fix" many of the problems I've been running into with the LTS Designer. Sometimes I can't drag tables onto the service. Sometimes I get validation errors (where nothing is actually wrong, but it won't let my project compile). Sometimes it seems saving the dbml file isn't rebuilding/regenerating what it should. Hmmmm.

July 22, 2009

# re: LINQ to SQL DBML fails to build or open

I needed to do this after opening my solution with Expression Blend 3...

I really want to use Blend but at every stage of its evolution I find that it is almost impossible due to some problem. I don't have time to learn how to code in a Blend-approved way.

Thanks for the tip!

August 04, 2009

# re: LINQ to SQL DBML fails to build or open

Aloha from Puna, Rick.

if your dbml is in its own assembly used by a project in a solution with an installer, devenv /ResetSkipPkgs isn't good enough.

You will also have to execute 'Build' (not rebuild) from the innermost assembly with the dbml, and then do Build on other assemblies, then Build again on your installer projects.

Fredrik S
September 29, 2009

# re: LINQ to SQL DBML fails to build or open

Thank you Dan. Sorted my issue

January 08, 2010

# re: LINQ to SQL DBML fails to build or open

Here it was apparently the "Get Latest" from the TFS server that caused the problem on my machine

January 29, 2010

# re: LINQ to SQL DBML fails to build or open

Thanks a lot, this solves my problem of being unable to create new .dbml LINQ to SQL classes.
I've read tens of other options, but this is the only thing that works.

Kathleen Dollard
February 01, 2010

# re: LINQ to SQL DBML fails to build or open

Just two add two other possible solutions...

I had not gotten any package load errors, so I just restarted all instances of VS. I had recently restarted my computer, and I've no clue what went wrong.

Also, Julie Lerman reported this problem when the coding was inadventently set to utf-16.

February 23, 2010

# re: LINQ to SQL DBML fails to build or open

Nice, worked for me, too. Don't want to know why. thx.

N M Reddy
May 10, 2010

# re: LINQ to SQL DBML fails to build or open

Thank you.. nice post..

I see we get this issue when we have installed VS 2010 and VS 2008 side by side.

West Wind  © Rick Strahl, West Wind Technologies, 2005 - 2024