A Programmer's Dream

Linq to Sql Error BC30002

Posted by Stephen Wrighton on 19 Nov 2010

I slammed up against a Yellow Screen of Death (YSOD) earlier today which just made my day.  And by "made my day" I mean that I wanted to scream, bang my head on the desktop, door and any other hard surface, and any other symbol of extreme frustration and angst which you deem appropriate.

Anyways, this YSOD, gave me the singularly helpful error message of:
BC30002: Type 'System.Data.Linq.Mapping.DatabaseAttribute' is not defined
Now, one would think that was helpful information. After all, it tells you exactly what's wrong, and it even tells you on which file it finds this bit of wrongness.

The problem comes in, when one considers that this particular file is a file that is generated by the Visual Studio IDE.  Worse yet, I was not getting any errors in Visual Studio at all.  Visual Studio was busy telling me how happy its little world was, while IIS was throwing up yellow every time I hit F5.

So, of course I turned to my good friend Google.

And found basically nothing. One person had gotten this error, and found out that it was due to conflicting namespaces.  Unfortunately, that wasn't the case here.

Then I did a slightly different Google search and discovered someone on the DNN boards who had gotten the same message, and that message is apparently an issue of the Web.Config not having all the required assemblies listed for it to do its thing with the LINQ classes.

I sat there for a moment, wondering how that could have happened to me. After all, I built the Web Site application from the ground up this morning.  I added the Linq-to-SQL classes via the IDE.  Visual Studio is supposed to take care of this for me, the same way it's done so a dozens of other times since VS2008 and Linq-to-SQL has came out.

Surprise!

Visual Studio hadn't.

Bascally, my Configuration/Compilation/Assemblies keys was missing this XML key:
add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />

After that was added I got a working website, and life once more became good...

Tweet me @kidananubix if you like this post.

Tweet