Issues with 32-bit dll on asp.net website

0

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:\repos\website\MyCo.Geometry\SqlGeometryWriter.cs:line 37 at MyCo.Geometry.SqlGeometryWriter.Write(LineString geometry) in

C:\repos\website\MyCo.Geometry\SqlGeometryWriter.cs:line 11 at MyCo.Web.Modules.harvestplan.HarvestPlanModule.<>c__DisplayClass0_0.<.ctor>b__7(Object _) in

C:\repos\website\MyCo.Web\Modules\harvestplan\HarvestplanModule.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!

iis
dll
visual-studio-2015
x86
asked on Stack Overflow Aug 22, 2018 by user25730 • edited Aug 22, 2018 by user25730

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.


User contributions licensed under CC BY-SA 3.0