Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
210 views
in Technique[技术] by (71.8m points)

c# - Unable to load SqlServerSpatial.dll

I am trying to use the SqlServer Spatial CLR types in a C# .Net project. I want to use SqlGeometry to query spatial records out of my db.

I have this working on my local machine in a unit test running in Visual Studio 2010 hitting a remote SqlServer machine. All good.

I then publish a WCF Rest service to my local IIS instance that has a service that hits the same class library as the unit test to do some spatial querying and it fails.

I get an error saying

Unable to load DLL SqlServerSpatial.dll : The specified module could not be found.

I have googled this and found many, many answers - none work for me. I have:

  • registered the CLR types with the GAC
  • install the 64-bit, and later also, the 32-bit version of the VC++
  • tried many variations of using different Microsoft.SqlServer.Types dll versions

The only thing I have not done, and frankly refuse to do, is to install anything on the actual SqlServer box. This seems unnecessary to me.

At this point the only thing that I can think is causing this is a permissions issue because it is running in an IIS app pool and not inside Studio where it works in the unit test.

Note that in my project I NEVER make reference to the dll mentioned in the error message. That dll is present on the sql box but I can't add it to studio as it gives some message when i try to. I'm running out of things to try here. It's 90's dll hell all over again.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I had the same problem on a Windows Server 2012 machine. It had an SqlServerSpatial110.dll file in WindowsSystem32, but no SqlServerSpatial.dll. The solution was installing the Microsoft System CLR Types for SQL Server 2008 R2 on the machine.

  1. http://www.microsoft.com/en-us/download/details.aspx?id=26728
  2. Click Download
  3. Check off one of these depending on your processor architecture:

    • 1033x64SQLSysClrTypes.msi
    • 1033x86SQLSysClrTypes.msi
    • 1033IA64SQLSysClrTypes.msi
  4. Click Next


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...