I’ve got an ASP MVC application where I am editing a field and posting the change back via Javascript like so:
"saveAndClose": function () {
var url = baseURL + "Product/UpdateProductFamily/" + $.trim($('#Id').text()) + "/" + $('#recordValue').val();
$.get(
url,
function (returnedData) {
alert('worked');
});
The call doesn’t even make it to the controller, instead I get an exception in the NHibernate Session manager:
private static void BeginTransaction(object sender, EventArgs e)
{
var x = NHibernateSessionManager.Instance;
x.BeginTransaction();
Thread.CurrentThread.Name = x.GetSession().GetSessionImplementation().SessionId.ToString();
}
The x.GetSession() line errors saying “The property is already set and cannot be modified”.
What’s going on here? Why is a simple JQuery get to the controller causing this NHibernate error?
The error you are getting is the result of trying to set the Name of the CurrentThread after it has been set.
http://msdn.microsoft.com/en-us/library/system.threading.thread.name.aspx
What I am not sure of, is why you need to set the name of the thread to the current session id.