Needing some help with Business Objects in ASP.Net PLEASE

G

Guest

I have an application in asp.net using vb.

The asp.net portion of this application is mainly the user interface. The
UI has references made to our business logic layer. And the business logic
layer uses a database class to access our data environment.

The business logic layer and database class is compiled into a class
library. The database class is a single class that contains all of our
queries there. It is implemented following the Singleton pattern so there
should only be 1 instance of the class.

The problem we are having is when multiple users start hitting the web site,
we get very erratic errors to occur at different points within the
application. All errors are System.InvalidOperationException. Invalid
attempt to read when reader is closed.

The application runs fine with 1 user on the system. So I know that the
code logic is ok. I am concerned that because I implemented a Singleton
database class, that all users in the system are trying to share that 1 class
instance.

Has anybody encountered this before?
Does anyone have any suggestions for me?

Some questions I would love to hear about are
1. When using class libraries, is a copy of the object model unique only at
the application level or at the session level?
2. Is there a way to specify at what level an object model may live within
an asp.net app?

Any feedback someone may have would greatly be appreciated. We have rather
hit a wall here and do not know how to continue.

Thanks.
 
S

sloan

You can check this article out:
5/24/2006
Custom Objects/Collections and Tiered Development
http://sholliday.spaces.live.com/


Some additional thoughts.
Make sure you do some locking with the Singleton.
Or abandon the Singleton thinking altogether.
How are you writing an Asp.Net singleton?
See
10/24/2005
Web Session Wrapper for storing and retrieving objects

Make sure you close your IDataReaders. Don't reuse connection objects.
It is less expensive to start a new connection object, then to tear one down
and build it back up.

I'd take a deep look at the first blog entry above, and then read the MS
article I mention at the bottom of that article.
On my blog, pay attention to the "SqlHelper is a substitute of your
application's data layer object".

I'd abandon a Singleton as a database class. Its more important to
Open LATE
Use quickly.
Close quickly.
Make sure you close and don't let connections linger. This is where I think
youre singleton is probably screwing you.
 
S

sloan

That's something MS did.

Its a IE issue, some SP they released on August.

Its something along the lines of "http 1.1" in the IE advanced options.

I don't know, it does the same for me.

You'd think an msn space page would actually work with IE.
 
D

David

Ah, OK, but it still is a big problem.

It even fails on firefox, but at least I get a chance to read the page on
FF. I reading it on my laptop, which is on my knee and it gets really hot,
so I saved the page to my HD, removed the script at the top and can read it.
(I could only do this in FF, IE crashed twice. I gave up with IE.).

Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
S

sloan

My FireFox works ok with it. (No crashes).

Yeah, I gave up on IE also. I have FF open .. with my blog stuff, and is
the only thing I have in FF.

I just did a Windows Update yesterday, so ............ I'm as good as I can
get with IE.

Crazy stuff, crazy stuff.
 
G

Guest

Sloan,

Thanks for the information, I am reviewing that now. I thought I would
write you back since you asked about how I implemented singleton in asp.net.

In my class library, as I mentioned, I have a database class that is my data
layer. In this class I have a private static variable that will hold the
single instance of the class.
So it would look something like this:

Public Class MyDatabaseClass
{
...
private static MyDatabaseClass dbInstance;
... //other private attributes

Public static MyDatabaseClass myDb()
{
if (dbInstance == null)
dbInstance = new MyDatabaseClass;
return dbInstance;
}
}

Everything else is implemented as instance methods or functions.

So now, elsewhere within the object model, this would be called as
MyDatabaseClass.mydb

I do agree with your assessment, however that the fact that I am using this
1 instance of a database layer is causing my problems.

Thanks for your help.
Guy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top