C# - How To Find Object In NHibernate/castle Activerecord Session

Aug 27, 2010

I am getting the following error in an Asp.Net Castle ActiveRecord app when trying to update an object:

"a different object with the same identifier value was already associated with the session"

I've looked up and down my code to see where else the object might have been created but I'm not seeing it. This is baffling as I have the exact same code on another page that works fine on updates

Now I'm thinking of trying to see where this other object is in the Session and either kill it or find out how it got into the session. How can I find this object?

[Update]

Ok, I finally found where the object is being called. However, I would still like to know how to find objects in the session for future reference.

View 1 Replies


Similar Messages:

Flush Separate Castle ActiveRecord Transaction And Refresh Object In Another Transaction

Jun 15, 2010

I've got all of my ASP.NET requests wrapped in a Session and a Transaction that gets commited only at the very end of the request. At some point during execution of the request, I would like to insert an object and make it visible to other potential threads - i.e. split the insertion into a new transaction, commit that transaction, and move on. The reason is that the request in question hits an API that then chain hits another one of my pages (near-synchronously) to let me know that it processed, and thus double submits a transaction record, because the original request had not yet finished, and thus not committed the transaction record.

So I've tried wrapping the insertion code with a new SessionScope, TransactionScope(TransactionMode.New), combination of both, flushing everything manually, etc. However, when I call Refresh on the object I'm still getting the old object state. Here's some code sample for what I'm seeing:

Post outsidePost = Post.Find(id); // status of this post is Status.Old
using (TransactionScope transaction = new TransactionScope(TransactionMode.New))
{
Post p = Post.Find(id);
p.Status = Status.New; // new status set here
p.Update();
SessionScope.Current.Flush();
transaction.Flush();
transaction.VoteCommit();
}
outsidePost.Refresh();
// refresh doesn't get the new status, status is still Status.Old

View 1 Replies

DataSource Controls :: Use Castle ActiveRecord With C#?

Mar 23, 2010

I'm trying to use Castle ActiveRecord with c#.

I'm moving data from an old database (FF2) to spatiaLite (sqLite)

The first few tables are updated without any problems. Then every table after gives and error

when I try to save. None of these tables have composite primary IDs.

SnapFarms tbl = new SnapFarms();
.... loop
if (theField.Equals("clientid")) tbl.operationId = getString(val, "{000-000}"); else
if (theField.Equals("farmid")) tbl.farmId = getString(val,"{000-000}"); else
if (theField.Equals("farmname")) tbl.farmName = getString(val,"Missing"); else ...
... end loop
tbl.Save();

exception message::Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

There is no Index column so what is going on?

View 4 Replies

NHibernate Mapping Method - Invalid Object Name Employee?

May 10, 2010

I am trying to configure NHibernate on my console application in which I am trying to map an Employee class to a table Employee.I am getting below exception which I have no clue:

Class:
class Employee
{
public int id;
public string name;
[code]...

View 3 Replies

Using Nhibernate In An Open Session Per View Approach?

Nov 28, 2010

I am using nhibernate in an open session per view approach where the session opens before the action method and closes right after. Using an AsyncController makes this model break because the controller performs data operations even when it has returned from the original XXXAsync method but it finds a null session while the HttpContext.Current is null as well. Is there any way to fix this issue?

View 1 Replies

C# - Keep Long Running NHibernate Session Data Consistent?

Sep 20, 2010

I have NHibernate sessions cached in the ASP.NET session.

I came across a situation where a user edited an object so it's in their first level cache in the ISession. Another user then edited the same object.

At this point User1 still sees their original version of their edits where as User2 sees the correct state of the object?

What is the correct way to handle this without manually calling session.Refresh(myObj) explicitly for every single object all the time?

I also have a 2nd level cache enabled. For NHibernate Long Session should I just disable the first level cache entirely?

Edit: Adding some more terminology to what I'm looking to achieve from 10.4.1. Long session with automatic versioning the end of this section concludes with

As the ISession is also the (mandatory) first-level cache and contains all loaded objects, we can propably use this strategy only for a few request/response cycles. This is indeed recommended, as the ISession will soon also have stale data.

I'm not sure what kind of documentation this is for it to include both probably and then immediately say the session will have stale data (which is what I'm seeing).

View 3 Replies

Populate An Unmapped Property Of Domain Object From Result Of Join With Nhibernate

Jun 7, 2010

I have a situation where I have 3 tables: StockItem, Office and StockItemPrice. The price for each StockItem can be different for each Office.

StockItem(
D
Name
)
Office(
ID
Name
)
[code]...

View 2 Replies

Web Forms :: Session Ended - But Server Error/ Object Reference Not Set To An Instance Of Object?

Nov 15, 2010

In the VS2005 environment, when I test my session to make sure the page redirects to the main page (itself) if the session is null, it works. There is no error.

The function I use for this is:

[code]....

However, when it is in the production environment in IIS 6.0, when the session has timed out, and I then do a postback by doing some slider control, I see the page reload but immediately thereafter, it throws a Server Error exception of : Object reference not set to an instance of object.

Looking at the stack trace, the event occured:

AJAXEnabledWebApplication1._Default.Slider1_TextChanged(Object sender, EventArgs e)

however, why is it that the Slider1_TextChanged event fired even even after during page_load, the page was told to do a response.direct ?? shouldn't the entire page have gone through a full-page refresh life cycle ? why did it continue on to attempt to raise the Slider1_TextChanged event?

View 1 Replies

Web Forms :: Error When Converting Session To String / Object Reference Not Set To Instance Of Object

May 7, 2015

I am getting object refernce error at line:if (Session["Tax"].ToString() == "9")

protected void Page_Load(object sender, EventArgs e)
{
if (Session["Tax"].ToString() == "9")
{
lblTax.Text = Session["Tax"].ToString();
}
else
{
lblTax.Text = "0";
}
}

Is anything wrong I have done?

View 1 Replies

Create A Copy Of An Object In Session To Update Without Updating Session?

Jul 20, 2010

I am confused about how to reference objects in session, how to update, and copy.

if I create
MyObject obj = new Object ();
then
Session["object"] = obj;
MyObject temp = (MyObject)Session["object"];

If i change something on temp, will the object in session be updated? do i need to follow changes with Session["object"] = temp?

View 2 Replies

State Management :: How To Manage Session Data Outside The Session Object

Oct 7, 2010

I want to be able to persist data across a session but do this outside of the built-in session state object. Why is a long story that I will not go into here. I just need to know where I can put data other than in the session object that will persist across the specific session.

View 3 Replies

ActiveRecord Initialize Method In Application_Start?

Dec 20, 2010

I have a site that uses ActiveRecord. I'm getting an exception that says "An ActiveRecord class () was used but the framework seems not properly initialized. Did you forget about ActiveRecordStarter.Initialize() ?" This is a web application, and the Initialize() method is called by the Application_Start event handler.

I created a new page that also calls the initialize() method. If I visit that page once, then the rest of the site works. If I visit it a second time, I get an exception stating that the Initialize() method can only be called once.

I've tried modifying the web.config and resetting the application pool to force Application_Start to run.

This only happens in production; dev, my stage, and client stage are fine. Production is the only load-balanced environment--I'm not sure if that comes into play.

Edit: We have another site deployed in the same environment which successfully uses ActiveRecord with the same initialization code. One difference is that the site that is working has only the ActiveRecord code in Application_Start; the site that doesn't also sets up some URL routing in Application_Start.

View 1 Replies

Web Forms :: Nhibernate Association / Not Set To An Instance Of Object At The Line "category.Products.Add(product);"

Apr 19, 2010

I am using nhibernate and performing one to many relation,

i have a parent table "Category" and child table as "product"

this is my code,

category.CategoryID = txtcategoryid.text;
category.CategoryName = txtName.Text;
category.CategoryDescription = txtDescription.Text;
product.CategoryID = category;
product.ProductName = txtProductName.Text;
product.ProductID = txtProductID.Text;
product.ProductDescription = txtProductDescription.Text;
category.Products.Add(product);
DAO.CanAddCategory(category);

but it throws exception, object reference not set to an instance of object at the line "category.Products.Add(product);"

View 9 Replies

Session - Object Reference Not Set To An Instance Of An Object?

Jun 19, 2010

I have this problem when trying to read a session in another asp.net page.

Object reference not set to an instance of an object.

If Session("cne").Equals("") Then Response.Redirect("Default.aspx")End If

I'm setting the session in the Default page with this code :

Session("cne") = cne.Text

View 1 Replies

C# - Subsonic 3.0.0.4 ActiveRecord Template For MySQL Error On Inserting New Record?

Nov 7, 2010

public void Add(IDataProvider provider){

var key=KeyValue();
if(key==null){
var newKey=_repo.Add(this,provider);
this.SetKeyValue(newKey);
}else{
_repo.Add(this,provider); //NullReferenceException was unhandled by user code

[Code]....

View 1 Replies

MVC :: Set Up IoC (Castle Windsor) In Project?

Feb 8, 2010

I'm trying to set up IoC (Castle Windsor) in my MVC 2 project here, using the section in Pro Asp.net MVC Framework book.

However, I cannot compile after creating a custom controller factory as stated in the book.

This part give me error:[Code]....

Telling me that no suitable method have been found to override?

Does someone know if there's a problem with the code in the book or something changed with recent versions of things (wont suprise me..got some books on MVC here rendered completely useless with the evolution of asp.net mvc)

View 12 Replies

Converting From StructureMap To Castle Windsor?

Mar 9, 2010

Recently, I've had some problems with StructureMap. Mostly incomplete documentation, but also they have a habit of drastically changing namespacing, object names, removing methods, and generally changing how the thing works.For now, my code is written using poor man's DI so that I can keep working on it, but I don't want to leave it that way. I took a look at Castle Windsor a while back, but never really tackled it.

With StructureMap, I would derive a custom Registry class where all the mapping is done, a custom Bootstrap class which loads one or more registry classes and initializes them, and then, call Configure on the bootstrap class in Global.asax.How does one go about setting up the matching Castle code? I also need to know how the controller factory is affected. Does Castle provide a replacement, or are we left to write our own, as with StructureMap

View 11 Replies

C# - Get The User's IP Address In Castle MVC (Monorail)?

Apr 26, 2010

In a controller action of a CastleMVC application, how can I get the user's IP Address?

I think in asp.net mvc it would be Request.ServerVariables["REMOTE_ADDR"], but I can't find an equivalent in Castle.

(I am aware of potential proxy issue's etc, the address that is reported in the request is fine)

View 2 Replies

Use System.Web.Routing In Castle Monorail?

Jul 21, 2010

Is it possible to use the Microsoft (or Mono) supplied System.Web.Routing instead of the MonoRail routing stuff when building a Castle MonoRail app for ASP.NET?

View 1 Replies

Castle Windsor IOC With Custom .NET Membership?

Feb 8, 2011

I have read about not being able to use a .NET Custom Membership with Castle Windor. Is this the case? Are there any work arounds?

View 1 Replies

C# - Get Current Sessions For Castle-Monorail Site?

Jan 28, 2011

I'm modifying a Castle-Monorail site that I've inherited and found that it would be useful to see a list of currently online users. Currently there are Filters that determine who can access which parts of the site so I can distinguish logged in sessions from non-logged in sessions. Is there an easy way of getting a list of active sessions so that I could then work out who is logged in?

View 1 Replies

Error "Object Reference Not Set To An Instance Of An Object" With Using Session

Dec 17, 2010

I am getting thid error Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error:

Line 18:
Line 19: <%&nbsp;
Line&nbsp;20:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;string&nbsp;thedate&nbsp;=&nbsp;Session["indate"].ToString();////;;;;????
Line&nbsp;21:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Response.Write("Starting&nbsp;SAS");
Line&nbsp;22:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try &nbsp; &nbsp;
Source&nbsp;File:&nbsp;c:Documents&nbsp;and&nbsp;SettingsAdministratorMy&nbsp;DocumentsVisual&nbsp;Studio&nbsp;2008WebSitesWebSite1SASrun.aspx&nbsp;&nbsp; &nbsp;
upload.aspx
<%@&nbsp;Page&nbsp;language="c#"Debug&nbsp;=true&nbsp;Codebehind="upload.aspx.cs"&nbsp;AutoEventWireup="false"&nbsp;
Inherits="Stardeveloper.UploadAccess.UploadForm"&nbsp;%>
<script runat="server">
void Button2_Click(object sender, EventArgs e)
{
Session["indate"] = Request["txtDate"];
Response.Redirect("SASrun.aspx");
}
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
</head>
<body>
<body style="background:#80B584">
<form runat=server>
<a href="default.aspx"><b>Main Page</b></a> · Upload Files
<div id="message" runat="server" />
<table align="left" border="0" cellspacing="0" cellpadding="3">
<p style="font-family:arial;color:White;font-size:20px;">Upload new files.</p>
<tr><td><b>MTMDetailed:</b></td><td><input type="file" class="stdInput" name="uploaded_file1"></td></tr>
<tr><td><b>File TRI_FP:</b></td><td><input type="file" class="stdInput" name="uploaded_file2"></td></tr>
<tr><td><b>indate :</b></td><td><input type="text"id="txtDate" name="inputdate"/></td></tr>
<tr><td align="right"><input type="submit" value="Submit"></td></tr>
<asp:Button id="Button2" runat="server" Text="Submit" onClick="Button2_Click" />
</table>
</form>
</body>
</html>

This is part of the code where error is coming from................

View 1 Replies

Find Object Tag Control?

Apr 7, 2010

I have object tag in my page. that object tag I am binding with protected string. my code is below. my aspx page

[Code]....

in my C# page

[Code]....

on the click event of the button 1 i want to find this object tag control and then i wnat some process on that.

View 2 Replies

How To Find Different Word From Object To Object2

Oct 18, 2010

i have 2 stringbuilder object. now i want to compare these 2 objects and have to find what is the different word from object to object2. how to do this?

View 1 Replies

DataSource Controls :: Cannot Find The Object 'AspNet_SqlCachePollingStoredProcedure'?

Jan 22, 2010

I have a Windows 2003 test server hosting an asp.net 2.0 application and Sql Server 2005 running as Sql Server 2000(80).During a recent a security review we decided that it wasn't such a hot idea to use sql authentication with an sysadm user as the database user for the asp.net application. Having done a bit of reading (http://msdn.microsoft.com/en-us/library/ms998258.aspx#pagguidelines0001_dataaccess) I decided to use a lower privilege database user account and windows authentication.Starting from scratch I created a new custom service account (http://msdn.microsoft.com/en-us/library/ms998297.aspx) and assigned this to the process identity for the application pool.I then created a new database login and user for this account. I added the db_datareader and db_datawriter roles to this user and I also granted EXECUTE permissions for user defined stored procedure and functions. However when I started the application I got this error 'User does not have permission to perform this action.Cannot find the object 'AspNet_SqlCachePollingStoredProcedure', because it does not exist or you do not have permission.' - after a quick hunt I found thishttp://forums.asp.net/p/1487216/3493362.aspx and followed the advice herehttp://msdn.microsoft.com/en-us/library/system.web.caching.sqlcachedependencyadmin.aspx and granted the user CREATE TABLE and CREATE PROCEDURE permissions.Still no joy - after digging around and looking at sql profiler I found what I believe to be the offending piece of sql:

/* Create notification table */
...sql
/* Create polling SP */
..more sql
..finally
GRANT EXECUTE ON dbo.AspNet_SqlCachePollingStoredProcedure to aspnet_ChangeNotification_ReceiveNotificationsOnlyAccess

My understanding is that to issue 'GRANT EXECUTE' the user must db_owner or db_secadmin. Indeed it all works fine if I give the service account user login the db_owner role.This sql is caused by: SqlCacheDependencyAdmin.EnableNotifications(ConnectionString), this is called once and once only by the application start event.Is there a work around for this? I would like to use the lower privilege account as per best practice but this issue is making it tricky.

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved