Issues with 32-bit dll on asp.net website - iis

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!

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.

Related

IIS in Classic Mode ignores Sitecore, does not loads the startItem

I am using Sitecore 8.1, and our IIS crashes quite often in production - on average, 2 times a day.
Following this guide to improve Sitecore stability on 64-bit machines I have set the Enable 32-bit Applications option to True and changed the application pool's Managed Pipeline Mode to Classic.
Sitecore now displays the empty "Default Page" page, and even after deleting its file it attempts to simply list the directory content rather than loading my Sitecore application as it always did in Integrated mode.
Does anyone knows how can I configure IIS in order to have Sitecore to work properly in Classic Mode?
This is not a solution to switch your Application Pool to Classic mode to stable your solution.
In Sitecore 8.1 : Classic mode for IIS has been deprecated, and the httpModules and httpHandlers elements have been removed from the Web.config file.
Informations about classic mode deprecated you can find here
It's very difficult to find exactly your problem, I suggest you to open a support ticket.
What you will want to do it catch the actual crash of the IIS app pool with DebugDiag. You install it and then configure it to watch your app pool until it crashes. Once it does, DebugDuag will dump the memory of the app pool to your hard drive. You can finally analyze that for the exact function and cause of the dump. You most likely have a process that is spinning off into a stack overflow in unmanaged code.
https://blogs.msdn.microsoft.com/chaun/2013/11/12/steps-to-catch-a-simple-crash-dump-of-a-crashing-process/

Getting Peformace Counter related error on Window Azure

I am facing some critical issue which might be interesting for whom , those who are playing with window azure sdk. I have created on EXE which read performance counter data like CPU, memory, asp.net session from system like
queryCollection = ExecuteWMIQuery("SELECT * FROM win32_perfformatteddata_perfdisk_physicaldisk");
and I have aded this EXE in startup task of simple asp.net application which i have uploaded on window Azure. Now when i connecting to RDP of that I can see following errors in my event log as per below.
Disabled performance counter data collection from the
"ASP.NET_64_2.0.50727" service because the performance counter library
for that service has generated one or more errors. The errors that
forced this action have been written to the application event log.
Correct the errors before enabling the performance counters for this
service.
======================================================================
Windows cannot open the 64-bit extensible counter DLL
ASP.NET_64_2.0.50727 in a 32-bit environment. Contact the file vendor
to obtain a 32-bit version. Alternatively if you are running a 64-bit
native environment, you can open the 64-bit extensible counter DLL by
using the 64-bit version of Performance Monitor. To use this tool,
open the Windows folder, open the System32 folder, and then start
Perfmon.exe.
So i am thinking that my EXE trying to fetch performance counter for 32 bit (win32 indicate that) and that will log above error.
So anyone here came across this type of issue , also if my guess is correct then is there any way to implement my EXE logic such way that it can be run smoothly in any environment(32 or 64 bit)?
Hope that this would remain interesting question here!!!
Thanks In Advance
Arun.
That is correct. IIS running in Azure is running 64-bit unless you change it to run 32-bit in a startup task. You could try building it with the Any CPU setting. But most likely the best way is to do something like what the sysinternal tools does. They will spawn a new process that runs in 64-bit mode when needed. Then you can handle both.
I encountered this error while migrating to a Azure VM.
Solved it by using the InstallUtil which is located in the Framework64 folder instead of the one in the Framework folder

WebApplication moss feature throws FileNotFound on one environment

I developed a certain feature at web application scope, I've deployed it in my development computer, activated it and it worked fine.
Once I've deployed it in out Test environment and tried to activate it, it throws "File Not Found".
The main difference between the servers which I think of is that the Central Admin in the Test env. is not a front-end, while in my dev computer everything is hosted on the same computer.
I think it has something to do with the feature trying to reach "propeties.Feature.Parent as SPWebApplication" (I can't debug the code in the test environment)
Any ideas ?
Thanks in advanced.
Ok, this is the second time I’ve had this problem, so I’m going to
blog about it so maybe I’ll remember next time. If you’re using VS
2010 and developing outside of IIS (console application in my case),
you need to make sure your project is not targeting the x86 Platform.
Go to your Project Properties, click the Build tab, and make sure the
Platform target dropdown is set to x64 (or Any Platform). Another less
than helpful error…
From FileNotFound Exception when creating SPSite or getting reference to SPWebApplication (SharePoint 2010)
Also see this post: FileNotFoundException with the SPSite constructor

Are there recent Microsoft changes affecting the behavior of AppInitDLLs registry entry?

I support a product that detects unique key combinations when pressed to launch a notification alert.
This monitoring is done by a dll that is injected. Originally this was done specifically to winlogon.exe, but due to some changes in Vista we added the reference to our dll in AppInitDLLs to have it injected into every running process.
This is not working on my newest development machine, and some behavior on client machines mimicks the behavior. Another dll listed, C:\Windows\system32\nvinitx.dll, is still correctly being loaded, but mine is not.
Are there any known recent security patches that may affect this?
there are no new security changes as far as I know, you can inject any dll (but it must be compatible with the process you are injecting into) like if the process is 32bit your dll must be 32 and if the process is 64bit u need to inject 64bit or odd behavior will appear. another things that there is a new bool value must be set in windows 7 (not sure in vista) that is
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\LoadAppInit_DLLs" must be set to one

deploying a winform application using clickonce and iis fails

I'm trying to deploy a winform application with IIS and ClickOnce. I can access the publish.htm page and the install even starts when I click on the provided link.
However I get this error during the installation process:
Downloading http://MyWebSiteUrl/.../Interop.SHDocVw.dll did not succceed.
The remote server returned an error: (500) Internal Server Error.
Can anybody help me out on this ?
Thanks,
Bruno
I found out that I needed to check "use .deploy file extension" (under properties>Publish>Options>Deployment
[Answering this old question because it comes up as the best match in my case and the accepted answer was of no use to me].
Background, in an IIS hosted ClickOnce scenario, the downloadable components are itemized in a manifest file at the root of the deployment (that's how you can specify a single download link and deploy all the supporting components).
I was converting a tested application from a WiX installation to a lightweight version with ClickOnce and received the HTTP 500 error without anything else in the logs. Naturally, I failed to think it through and instead found myself getting dragged down the rabbit hole on the internets, with instructions for detailed logging, magic spells, etc.
Upon more sober reflection, the problem was simple and I should have been able to tell immediately from the IIS log: a 500 followed by a 0 is shorthand for 'you're an idiot, the content isn't where you said it was' and it had almost nothing to do with ClickOnce.
I had copy/paste/edited an existing download link template in MVC that was in use for simple apps and it happened to cater to only two levels of subfolders in the manifest. When I ported a more complex project structure, I ended up leaving items in a Resources sub-sub-subfolder that looked fine in the manifest but the path was being truncated in MVC so that the related item could not be found.
Moral of the story - if you get a 500 error always check first to make sure your non-functioning appliance is plugged into a working outlet...

Resources