none
Database project is referencing wrong .Net Framework version

    Question

  • In Visual Studio 2010 I've created a Database project and specified Target .Net Framework 3.5 (for SQL CLR code). Within the code there is a reference to TimeZoneInfo class.

    Now I am getting an error message

    The type 'System.TimeZoneInfo' exists in both 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll' 

    Now the question is - why the project is trying to look at Framework\v4.0.30319\mscorlib.dll at all? It does not belong to the target framework specified.

    This error is preventing project from building. Is there any workaround?

    Thursday, December 13, 2012 5:09 PM

Answers

  • I'm going to close this since the question is very old at this point.  If you're still having problems make sure the TargetFrameworkVersion is 3.5

      <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>

    Also, make sure you don't have any references to 4.0 assemblies.  In my project used to try and repro this issue here are my references:

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

    Monday, September 09, 2013 3:54 AM
    Owner

All replies

  • Maybe you included an explicit assembly references which conflicts with the selected CLR target version? The CLR target version of the project is listed in the SQLCLR tab.


    -GertD @ www.sqlproj.com

    Thursday, December 13, 2012 10:44 PM
    Moderator
  • Maybe you included an explicit assembly references which conflicts ...

    No I did not include any references to .Net Framework 4 assemblies. The Framework\v4.0.30319\mscorlib.dll was put by Database projects itself and it is beyond of my control.

    Actually the problem I am describing is very easy to reproduce. Just try to use TimeZoneInfo class in  targeted to .Net Framework 3.5 Database project.

    Friday, December 14, 2012 4:48 AM
  • I'm going to close this since the question is very old at this point.  If you're still having problems make sure the TargetFrameworkVersion is 3.5

      <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>

    Also, make sure you don't have any references to 4.0 assemblies.  In my project used to try and repro this issue here are my references:

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

    Monday, September 09, 2013 3:54 AM
    Owner