none
WebAPI error on azure, but works fine locally {"$id":"1","Message":"An error has occurred."}

    Question

  • I call the webAPI I create with MVC4 in Visual studio 2012  and get  a continuous loading error.

    When I call the WebAPI locally it works, but when on azure I receive the message {"$id":"1","Message":"An error has occurred."}.

    I have tested this api call in Fiddler and it returns correct results locally, but when I use fiddler to check on azure, I get the above error message.

    Thank you for any help.

    The full error message is below.  (I am worried that there is an issue with sql as the following error states this 'Spatial types and functions are not available for this provider because the assembly 'Microsoft.SqlServer.Types' version 10 or higher could not be found' below:

    I fixed this issue by disabling proxies and getting the Nuget package MSSQL.ServerTypes

    Thursday, November 29, 2012 1:02 AM

Answers

  • Hi Brad,

    I think you have to "set copy local" for Microsoft.SqlServer.Types assemblies. If it requires SqlServerSpatial110.dll, copy it from the sysWOW64 to your site's bin folder.

    WAWS worker process runs in WOW64 mode.

    Thanks,

    Wei

    • Marked as answer by brad_unbuythat Friday, November 30, 2012 12:04 PM
    Friday, November 30, 2012 5:05 AM
    Moderator

All replies

  • It works for me.

    Thursday, November 29, 2012 2:07 AM
    Moderator
  • Thank you for looking a this. I just fixed it.

    Thursday, November 29, 2012 2:10 AM
  • I just looked again and now get a new error, still related to the SQL Spatial problem.

    I am still looking around for an answer, but with no luck.

    {"$id":"1","Message":"An error has occurred.","ExceptionMessage":"Unable to load DLL 'SqlServerSpatial.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)","ExceptionType":"System.DllNotFoundException","StackTrace":" at Microsoft.SqlServer.Types.GLNativeMethods.GeodeticDistance(GeoMarshalData g1, GeoMarshalData g2, EllipsoidParameters ellipsoidParameters, Double& result)\r\n at Microsoft.SqlServer.Types.GLNativeMethods.GeodeticDistance(GeoData g1, GeoData g2, EllipsoidParameters ellipsoidParameters)\r\n at Microsoft.SqlServer.Types.SqlGeography.STDistance(SqlGeography other)"}



    • Edited by brad_unbuythat Monday, December 03, 2012 8:21 AM removed deadlink
    Thursday, November 29, 2012 3:52 AM
  • In the VS solution explore, find the reference of this dll, and the "copy local" to true. Then deploy the site again, this dll will be deployed with your application.

    Thursday, November 29, 2012 6:38 AM
    Moderator
  • Thank you very much for your rapid response. I have not been able to find this dll.  I am currently looking to see how to download it. It does not seem to be on my computer.  There are several posts stating that this dll has a problem on azure, so I am looking into this further.
    Thursday, November 29, 2012 10:10 AM
  • After doing lots of reading and looking in my project. the System.Data.Entity was the dll that needed to be added to my project to get DBGeography working. I added the keep local, but this did not fix the issue for me either.

    I have installed the new version of MsSqlServer.Types and this did not fix the issue either.

    Thursday, November 29, 2012 10:21 AM
  • I have now added the latest Microsoft. SQLServer.Types and get a new error message 

    {"$id":"1","Message":"An error has occurred.","ExceptionMessage":"Unable to load DLL 'SqlServerSpatial110.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)","ExceptionType":"System.DllNotFoundException","StackTrace":" at Microsoft.SqlServer.Types.GLNativeMethods.GeodeticPointDistance(Point p1, Point p2, EllipsoidParameters ep)\r\n at Microsoft.SqlServer.Types.SqlGeography.STDistance(SqlGeography other)"}

    I am not having luck with these DLL's

    I have also set 'copy local' to be true and this still does not work.

    Thursday, November 29, 2012 10:47 AM
  • Shot in the dark here, but are you sure that the version of ASP.NET is set correctly in the portal?


    Jim Cheshire | Microsoft

    Thursday, November 29, 2012 5:30 PM
    Moderator
  • Thank you for your answer.  In the portal it is set to 4.5.

    the error occurs when the DBGeography type is trying gets invovled. I am looking at this now to see if there is something else I can use for working with Spatial distance in Azure websites.


    • Edited by brad_unbuythat Thursday, November 29, 2012 7:49 PM edit mispellings
    Thursday, November 29, 2012 7:22 PM
  • <cite class="fn" style="margin:0px;padding:0px;">Jonathan Kallay </cite>
    November 17, 2012 at 4:36 pm

    Be aware that your sample will work, but what won’t work is a web application that retrieves geometry from SQL Azure, because SQL Azure is currently running Denali (SQL Server 2012) at compatibility level 100; hence it will return instances of the 10.0 spatial types and the web role will throw an exception when trying to cast them to 11.0.

    I hope that this is not a problem for me as it is  SqlServerSpatial110.dll on Azure websites

    Thursday, November 29, 2012 10:21 PM
  • I have uninstalled the Microsoft. SQLServer.Type, which brought me back to my original error message, and then tried to add dll's from the system32 and sysWOW64, but get errors saying the sqlserverspatial.dll could not be added. please make sure that the file is accessible, and that it is a valid assembly or Com component.

    I have tried to copy the dll directly and this has not helped.  I am looknig to see if there is anything else to do, but I do not see anything.

    Can anyone help?

    Thank you,

    Friday, November 30, 2012 4:08 AM
  • Hi Brad,

    I think you have to "set copy local" for Microsoft.SqlServer.Types assemblies. If it requires SqlServerSpatial110.dll, copy it from the sysWOW64 to your site's bin folder.

    WAWS worker process runs in WOW64 mode.

    Thanks,

    Wei

    • Marked as answer by brad_unbuythat Friday, November 30, 2012 12:04 PM
    Friday, November 30, 2012 5:05 AM
    Moderator
  • I did this when you requested that I do it earlier.  This did not change anything.

    The dll is on the server I can see this in the bin folder on azure.  But I will try again and let you know what happens.

    Friday, November 30, 2012 11:54 AM
  • I have to thank you so much.  I did this from the system32 before and what you suggested from the WOW64 corrected this issue.   

    We go live in 5 hours and you saved me thank you so much.

    Have a great day.

    Friday, November 30, 2012 12:04 PM
  • nice to know it works:-)
    Monday, December 03, 2012 6:19 AM
    Moderator
  • Brad - I am running into the same problem.  How did you get around the error "sqlserverspatial.dll could not be added. please make sure that the file is accessible, and that it is a valid assembly or Com component."

    And did you grab the DLL from your local machine?

    Thanks!

    Sunday, February 24, 2013 1:05 AM
  • The way that this was fixed, was by adding the "sqlserverspatial.dll" to the bin folder in Visual Studio 2012 and then publishing this to Azure.

    The file needs to be the C:\Windows\SysWOW64\sqlserverspatial.dll

    I used ftp to get this there first and it worked well, but needed to be manually placed there each time until I put it in bin folder in Visual studio.

    Sunday, February 24, 2013 2:14 AM
  • Thanks Brad - One more clarification.  When you say bin folder in Visual Studios 2012, do you mean the project's bin folder?  Specifically "Release"?

    Thanks!

    Sunday, February 24, 2013 4:30 AM
  • Finally got this working.  The funny thing is that the sqlserverspatial.dll did not work, but the version in c:\windows did work.  I was getting a System.BadImageFormatException when solution tried using the dll from the C\Windows\SysWOW64 directory.

    Sunday, February 24, 2013 1:39 PM
  • A quick question.  Are you doing with on Windows Azure?  As I thought Windows Azure was 64 bit.

    Monday, February 25, 2013 6:01 PM
  • Windows Azure Web Sites runs in 32-bit mode on 64-bit Windows.


    Jim Cheshire | Microsoft

    Monday, February 25, 2013 6:18 PM
    Moderator
  • I'm not sure whether something has changed in Azure since your post, or whether our local environments are just different (probably the latter, but who knows), but for anybody else struggling with this, here's what I did.  Our site is running as an Azure Cloud Service using EF5 (with some DbGeography type properties), and SQL Azure (which has columns of type geography).  This was, at first, borking when myDbGeography.Distance(otherDbGeography) was called on Azure.

    I ended up referencing the DLLs that are mentioned in the blog, "Spatial Applications in Windows Azure Redux (including Denali)", but used 64-bit versions of assemblies instead of the 32-bit versions.  BUT - and this was the catch, at least for me - I used SqlServerSpatial110.dll from Program Files\Microsoft SQL Server\110\LocalDB\Binn (so, the LocalDB version) and NOT from SysWOW64.  Also, I had to use the version of Microsoft.SqlServer.Types.dll from Program Files\Microsoft SQL Server\110\Shared\ folder.

    The project itself (the MVC4 project) was set to platform=AnyCPU and Target=AnyCPU.  If anyone needs the exact file versions of the dlls, let me know.  The msvcp100.dll and msvcr100.dll did come from SysWOW64.

    Monday, October 07, 2013 8:58 PM