Tip: Get back your System.Linq; er, reference to System.Core in VS2010

By erik at October 05, 2010 01:39
Filed Under: .NET, Software Development

If you’re like I am, then you can’t stand all the garbage references and using statements in some of the VS Project and Item templates, and instantly remove many of those references.  I talk myself into doing that by reasoning that if I need an assembly reference – that I want to overtly make the choice myself, so that I can think about what the dependency on that component assembly is providing to my current layer.

Well, tonight I got burned by removing references from project templates to System.Core, and finding out that in fact when you try to re-reference this assembly, it still shows in VS2010 as selected, as such:

Solution references showing no reference to System.Core:

image

Note the Add Reference Dialog showing an existing reference to System.Core:

image

What gives?  Well, I blogged this because the solution was not quite straightforward, but trivial when you think about it.  I simply opened up my .csproj file and added the reference in manually using Notepad2, and reloading the project when prompted to do so by VS2010.  Here’s how to add the reference in:

  <ItemGroup>
    <Reference Include="System.Core" />
  </ItemGroup>

Note that the <Reference /> node can be included in another <ItemGroup /> if one exists.

By the way, if you’re wondering about the reference to System.Linq: well – it is in System.Core.dll.  That’s the connection…

Hope this helps someone.

Add comment




  Country flag

biuquote
Loading



Visitors

Disclaimer

Views expressed are my own and in no way represent those of my employer; this is in no way a work or work-related blog.  All postings are presented "AS IS" and confer no rights.

Copyright

All content copyright © 2009-2011 by Erik Mlincek.  You may not use content without the express written consent of the author, however you may link back to blog topics hosted at mlincek.com without obtaining permission in advance.