none
Database project is dropping references to .Net assemblies

    Question

  • In Visual Studio 2010 create a Database project and add some references to .Net assemblies (which are necessary for SQL CLR code to work). This works fine so far, the project builds.

    Now close Visual Studio and open it again. All references are gone... The code is showing some syntax problems.

    What is the workaround?

    Thursday, December 13, 2012 4:58 PM

Answers

All replies

  • No sure what is going on on your machine. Can you look inside your project file, there must be an ItemGroup that contains the references like this:

     <ItemGroup>
        <Reference Include="System" />
        <Reference Include="System.Data" />
        <Reference Include="System.Xml" />
        <Reference Include="SqlProjClr">
          <HintPath>SqlProjClr.dll</HintPath>
          <SqlOwnerName>dbo</SqlOwnerName>
          <GenerateSqlClrDdl>True</GenerateSqlClrDdl>
          <IsModelAware>True</IsModelAware>
        </Reference>
      </ItemGroup>

    After you save the project does this block exist? When you re-open and it does not re-appear can you check the it actually gone from the project file?

    -GertD @ www.sqlproj.com

    Thursday, December 13, 2012 11:08 PM
    Moderator
  • No sure what is going on on your machine. Can you look inside your project file, there must be an ItemGroup that contains the references like this:

     <ItemGroup>
        <Reference Include="System" />
        <Reference Include="System.Data" />
        <Reference Include="System.Xml" />
        <Reference Include="SqlProjClr">
          <HintPath>SqlProjClr.dll</HintPath>
          <SqlOwnerName>dbo</SqlOwnerName>
          <GenerateSqlClrDdl>True</GenerateSqlClrDdl>
          <IsModelAware>True</IsModelAware>
        </Reference>
      </ItemGroup>

    After you save the project does this block exist? When you re-open and it does not re-appear can you check the it actually gone from the project file?

    -GertD @ www.sqlproj.com

    The references really can be seen in the project file (if I open it in a text editor). But they are not shown in Visual Studio. And what is the most concerning - all statements in C# code, which refer to classes from these assemblies, are now showing syntax errors.

    This is how the relevant section of the project file looks like:

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

    As we may see it duplicates the same references many times. And this is result of atempts to insert them back every time they disappear.

    The problem is very easy to reproduce. Just add some .Net references then close and reopen Visual Studio.


    Friday, December 14, 2012 4:59 AM
  • This was a valid bug, thanks for reporting it.  It's been fixed in the latest version of SSDT.

    http://msdn.microsoft.com/en-us/data/hh297027

    Monday, September 02, 2013 9:18 PM
    Owner