I have a small web application which runs fine on my PC, but when I publish it to the server, the app crashes when querying the database.
I have narrowed it down to this line:
output = (List<Pallet>)db.Query<Pallet>(query, args);
Where I am using Dapper
to query a table.
Normally when an error occurs it takes me to the shared ASP errors page, but here I just get a This site can’t be reached
ERR_CONNECTION_RESET
in Chrome.
I also noticed that in the Event Viewer an Application Error appears with Event ID of 100
:
Faulting application name: w3wp.exe, version: 8.0.9200.16384, time stamp: 0x5010885f
Faulting module name: mso30win32client.dll, version: 16.0.4266.1001, time stamp: 0x55ba12f1
Exception code: 0xc0000005
Fault offset: 0x00088092
Faulting process id: 0x35a4
Faulting application start time: 0x01d2cce79551069b
Faulting application path: C:\Windows\SysWOW64\inetsrv\w3wp.exe
Faulting module path: C:\Program Files (x86)\Common Files\Microsoft Shared\Office16\mso30win32client.dll
Report Id: f044a40f-38da-11e7-9402-a4bf011a3e0b
Faulting package full name:
Faulting package-relative application ID:
Here is the method in GrvController
:
public ActionResult Details(string grvNumber)
{
var pallets = access.GetPallets(grvNumber);
var grv = new Grv(pallets);
Session["grv"] = grv;
return View(grv);
}
And Access.GetPallets
:
internal List<Pallet> GetPallets(string grvNumber)
{
using (var db = new OleDbConnection(ConnectionString))
{
var query = Constants.GetGrvQuery;
var args = new DynamicParameters();
args.Add("@grv", grvNumber);
var output = new List<Pallet>();
try
{
output = (List<Pallet>)db.Query<Pallet>(query, args);
}
catch (Exception e)
{
Log.Debug(e.Message);
}
return output;
}
}
Note that Exception e
is never caught, and the application just crashes after a delay.
Has anyone experience this before? Does anyone know how I can go about debugging this?
Thanks in advance.
Update
I tried changing my GetPallets
method to see if the issue was Dapper
specific, but it is doing the same thing when calling OleDbConnection.Open()
.
I also noticed that in my event viewer, there is a constant stream of this application error:
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'. Reason: Could not find a login matching the name provided. [CLIENT: <named pipe>]
from source MSSQL$MICROSOFT##WID. Could it be that this is somehow related?
My application is set up to use a service account created in AD.
Update 2
Thanks to Austins comments, I believe its been narrowed down further to being some sort of permissions issue with an internal MS database. When I change the web app to run as administrator
instead of my serviceQC
account, it can access the database without any issues.
However, this is of course not good practise. I tried adding all of the groups in administrator
s "member of" tab in AD to serviceQC
, but that doesn't help. Does anyone know how I can grant access to the MSSQL$MICROSOFT##WID database for a specific user?