Issues with 32-bit dll on asp.net website

Issues with 32-bit dll on asp.net website



Having trouble with an asp.net website (running VS2015) which uses a 32-bit dll.



Basically, one part of the website needs to run SqlServerSpatial. This apparently comes from the Microsoft.SqlServer.Types. All has been installed from NuGet before I arrived in the job, and appears referenced correctly.



However, I believe this is a 32-bit dll. Upon trying to perform an operation which requires it, we get this error:



System.DllNotFoundException was unhandled by user code



HResult=-2146233052



Message=Unable to load DLL 'SqlServerSpatial.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)



Source=Microsoft.SqlServer.Types



TypeName=""



StackTrace:



at Microsoft.SqlServer.Types.GLNativeMethods.IsValid(GeoMarshalData g, Boolean& result)



at Microsoft.SqlServer.Types.GLNativeMethods.IsValid(GeoData g)



at Microsoft.SqlServer.Types.SqlGeometry.IsValidExpensive()



at Microsoft.SqlServer.Types.SqlGeometryBuilder.get_ConstructedGeometry()



at MyCo.Geometry.SqlGeometryWriter.Construct(OpenGisGeometryType geomType, LineString geometry) in



C:reposwebsiteMyCo.GeometrySqlGeometryWriter.cs:line 37
at MyCo.Geometry.SqlGeometryWriter.Write(LineString geometry) in



C:reposwebsiteMyCo.GeometrySqlGeometryWriter.cs:line 11
at MyCo.Web.Modules.harvestplan.HarvestPlanModule.<>c__DisplayClass0_0.<.ctor>b__7(Object _) in



C:reposwebsiteMyCo.WebModulesharvestplanHarvestplanModule.cs:line 164
at Nancy.Routing.DefaultRouteInvoker.Invoke(Route route, DynamicDictionary parameters, NancyContext context)
at Nancy.Routing.DefaultRequestDispatcher.Dispatch(NancyContext context)
InnerException:



Most stuff I've read seems to indicate this is down to using a 32-bit dll, and the freelance dev we use is telling me to change my IIS settings to enable 32-bit mode. Trouble is, when I've gone to this (change platform target in the project build settings), it's currently set to "Any CPU". Changing it to 32-bit gives a System.Exception in mscorlib.dll. Only other IIS I can think of is on my machine - surely any changes I do in that wouldn't be deployed.



Sorry - just getting quite frustrated that something that should be simple is eluding me.



EDIT - well, turns out the previous staff had left a load of nice little surprises for us, lots of different versions of SqlServerSpatial and Microsoft.SqlServer.Types lurking around the code that needed straightening out. Can't really say anything was the answer but there's a few suggestions which may help people in the future, so upvotes for all!





"I believe this is a 32-bit dll" Are you sure? Or perhaps the DLL does not exist at all. Both cases result in the same error. Related: Unable to load SqlServerSpatial.dll.
– Hadi Brais
Aug 22 at 1:33





Yep - it is there, checked the solution (has been added to the solution), checked the file exists. According to link it is 32-bit.
– user25730
Aug 22 at 1:40





I suggest you use one of the tools to diagnose DLL binding. You can determine what kind of SqlServerSpatial.DLL is being looked for and whether it's found in a particular directory. If the DLL found was indeed 32-bit but the process is 64-bit then obviously it cannot be loaded. Similarly, if it was 64-bit but the process is 32-bit (WoW64) then it cannot be loaded. You can choose one of the following tools: sxstrace.exe (which can be used for any DLLs), fuslogvw.exe (which can only be used for .NET DLLs, which SqlServerSpatial is), or Process Monitor.
– Hadi Brais
Aug 22 at 2:02





Interesting. Given SxsTrace a go but the outfiles (parsed) are empty. Will have a few more goes soon.
– user25730
Aug 22 at 2:31




1 Answer
1



To run an IIS application in 32bit mode you don't change the platform target in Visual Studio, Any CPU is fine. You need to set the hosting process to be launched as 32bit.



This is done in IIS as a setting on the Application Pool to which the application is mapped. Set the "Enable 32-Bit Applications" setting on the Application Pool, and the apps in that pool will be 32bit.





Good, but not quite. Unless I'm missing something (probably am). Have found the appropriate app pool, set it to 32-bit, stopped it, started it again, and run. Still throwing up the same "unable to load dll SqlServerSpatial.dll" error. Seems to be exactly the same one.
– user25730
Aug 22 at 0:18






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế