none
Entity framework can't make updates in db (missing entry point SetClrFeatureSwitchMap in SqlServerSpatial110.dll) RRS feed

  • Question

  • Hello,

    our company develops application working with SQL server using entity framework. Yesterday I noticed, that application is unable to update records in database with this exception detail:

    System.TypeInitializationException: The type initializer for 'ExtentPlaceholderCreator' threw an exception. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.EntryPointNotFoundException: Unable to find an entry point named 'SetClrFeatureSwitchMap' in DLL 'SqlServerSpatial110.dll'.

    I suspect it was caused by installation of SQL2012 SP3 (KB3072779), but uninstalling this update didn't help. I've also tried to uninstall whole SQL server and install it again - also no success.

    Application uses EF 4 (EntityFramework.dll has version 4.4.0.0), SQL server is:

    Microsoft SQL Server 2012 - 11.0.2100.60 (X64)
        Feb 10 2012 19:39:15
        Copyright (c) Microsoft Corporation
        Developer Edition (64-bit) on Windows NT 6.2 <X64> (Build 9200: )

    SqlServerSpatial110.dll is version 2011.110.5058.0 from May 15th, 2014

    Apparently it is problem of Entity framework, as another application using EF6 + SQL2014 works correctly. Seems there was some update, which didn't updated SqlServerSpatial110.dll to correct version.

    The only solution found at Google was uninstall everything related to SQL server - what is problem when SQL server runs locally. Has someone any working solution of this problem?

    Thank you in advance,

    Radovan

    Wednesday, December 16, 2015 10:01 AM

Answers

  • So, after a long time there's final update.

    There is no solution from Microsoft - although I was able to demonstrate problem on my machine and MS support guy took tons of logs to analyze, they were unable to reproduce problem.

    But here (https://connect.microsoft.com/SQLServer/Feedback/Details/2139143) is mentioned SQL2012 SP3 postfix, which helped to one user, so I wanted to test it myself. For this reason I had to apply SQL2012 SP3 again, as I uninstalled it previously. I've used standalone installer downloaded form MS site.

    Surprisingly, when SP3 was applied, application started to work without any error, so mentioned postfix was not necessary.

    It appears to me, that there was some error during initial SP3 installation (which was done through Windows update over company WSUS server), while standalone installer is OK.

    So I'd recommend to always install SQL2012 SP3 using standalone installer, which should be fine. If not, use this assembly redirection in app.config:

    <runtime>

      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

        <dependentAssembly>

          <assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" />

          <bindingRedirect oldVersion="1.0.0.0-11.0.0.0" newVersion="10.0.0.0" />

        </dependentAssembly>

      </assemblyBinding>

    </runtime>

    Both of these solutions worked for me on two different machines.


    • Marked as answer by radek.raszka Thursday, May 5, 2016 7:39 AM
    Thursday, May 5, 2016 7:38 AM

All replies

  • I also have gotten this error.   If you find the solution, please post.
    Wednesday, December 16, 2015 9:16 PM
  • As I could solve it myself, I opened support request to Microsoft.
    Thursday, December 17, 2015 12:50 PM
  • I have also started seeing this error. It has something to do with the Microsoft.SqlServer.Types nuget package.

       at Microsoft.SqlServer.Types.GLNativeMethods.SetClrFeatureSwitchMap(Int32 clrFeatureSwitchMap)
       at Microsoft.SqlServer.Types.SqlGeometry.IsValidExpensive()
       at Microsoft.SqlServer.Types.SqlGeometry..ctor(GeoData g, Int32 srid)
       at Microsoft.SqlServer.Types.SqlGeometry.Construct(GeoData g, Int32 srid)
       at Microsoft.SqlServer.Types.SqlGeometry.GeometryFromText(OpenGisType type, SqlChars text, Int32 srid)
       at Microsoft.SqlServer.Types.SqlGeometry.STGeomFromText(SqlChars geometryTaggedText, Int32 srid)
       at Microsoft.SqlServer.Types.SqlGeometry.Parse(SqlString s)

    Exception Text is "Unable to find an entry point named 'SetClrFeatureSwitchMap' in DLL 'SqlServerSpatial110.dll'."

    This package has SqlServerSpatial110.dll as part of its content files so it get copied to the bin folder.

    The package description says:
    "Allows you to use SQL Server spatial types on a machine without SQL Server installed."

    so I am guessing the SQL Server you have installed locally doesn't affect this.

    Thursday, December 17, 2015 1:43 PM
  • Please make sure to post whatever you get told. Seems to me to be some new patches really have messed things up. It is just a DEV server for me and hoping to know a fix before patches hit prod.
    Friday, December 18, 2015 3:22 AM
  • The submitted the issue with microsoft here:

    https://connect.microsoft.com/SQLServer/Feedback/Details/2139143

    I also added a workaround for the issue which I deem "Just OK" but it lets you keep going.

    Please feel free to up-vote and comment on this issue there as well.

    Friday, December 18, 2015 3:00 PM
  • I've commented on the issue you created.  Can confirm in my case it was due to dll shipped in SQL Server SP3.  I had to uninstall the patch but the newer dll was still in the gac so I had to overwrite with the older version using gacutil.
    • Edited by snowcow Thursday, January 14, 2016 12:41 PM
    Thursday, January 14, 2016 12:41 PM
  • How did Microsoft resolve this issue? I believe a lot of people will be interest to know.

    By the way, what is the code your have to get this error, I don't see any EF code here?

    chanmm


    chanmm

    Friday, January 15, 2016 12:37 AM
  • Hello to all, here' some update:

    so far, no recommendation from Microsoft, they contacted me first time yesterday, one month after creating support request (quite quickly, isn't it?). So they just started to work on the issues.

    However, I found this solution:

    http://stackoverflow.com/questions/34204990/entitfy-framework-cannot-update-database

    and it works for me. Simply redirect Microsoft.SqlServer.Types assembly to version 10.0.0.0 in app.config / web.config and problem disappears, data updates work again. Also version 12.0.0.0 works correctly according workaround described in

    https://connect.microsoft.com/SQLServer/Feedback/Details/2139143

    (not tested by me, but application using EF6 has no problem). However I'm interested what Microsoft will propose, apparently there's some DLL mismatch, which should be solved.

    Radovan

    Tuesday, January 19, 2016 7:13 AM
  • So, after a long time there's final update.

    There is no solution from Microsoft - although I was able to demonstrate problem on my machine and MS support guy took tons of logs to analyze, they were unable to reproduce problem.

    But here (https://connect.microsoft.com/SQLServer/Feedback/Details/2139143) is mentioned SQL2012 SP3 postfix, which helped to one user, so I wanted to test it myself. For this reason I had to apply SQL2012 SP3 again, as I uninstalled it previously. I've used standalone installer downloaded form MS site.

    Surprisingly, when SP3 was applied, application started to work without any error, so mentioned postfix was not necessary.

    It appears to me, that there was some error during initial SP3 installation (which was done through Windows update over company WSUS server), while standalone installer is OK.

    So I'd recommend to always install SQL2012 SP3 using standalone installer, which should be fine. If not, use this assembly redirection in app.config:

    <runtime>

      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

        <dependentAssembly>

          <assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" />

          <bindingRedirect oldVersion="1.0.0.0-11.0.0.0" newVersion="10.0.0.0" />

        </dependentAssembly>

      </assemblyBinding>

    </runtime>

    Both of these solutions worked for me on two different machines.


    • Marked as answer by radek.raszka Thursday, May 5, 2016 7:39 AM
    Thursday, May 5, 2016 7:38 AM
  • Thank you so much for posting this answer. It really got me out of a jam today.  The app.config changes worked for me. 
    Friday, February 24, 2017 8:02 PM