System.UnauthorizedAccessException

If you are having a problem using Fortress, post a message here.

Moderator: SourceGear

Beth
Posts: 8550
Joined: Wed Jun 21, 2006 8:24 pm
Location: SourceGear
Contact:

Re: System.UnauthorizedAccessException

Post by Beth » Wed Mar 10, 2010 5:45 pm

What is your app supposed to do?

It could be a case where both are trying to load the repository at the same time and it's locked temporarily. What you may need to add to your code is something for process/thread synchronization. What happens if you try that?
Beth Kieler
SourceGear Technical Support

dprothero
Posts: 44
Joined: Sun Mar 21, 2004 12:18 pm
Location: Stockton California
Contact:

Re: System.UnauthorizedAccessException

Post by dprothero » Wed Mar 10, 2010 5:58 pm

The app as 4 different operations it performs: a) get latest version of a file or files, b) check-out a file or files, c) check-in a file or files and add to an existing label.

Each time the user requests one of these operations, the process is: 1) connect to vault repository, 2) perform selected operation, 3) close vault connection.

So, if two users were doing the same thing simultaneously, we are positing that this could cause the access violation.

The only problem is, this being an ASP.NET application, the threads are not under our control.

I'm thinking the only way to synchronize these operations would be to write some kind of stand-alone service that processes requests serially from a queue (like a database table). The ASP.NET application would just write the requests to the queue and wait for the service to process them.

That's a lot of development effort, however, so I was just wanting to explore any other options there might be.

David

dprothero
Posts: 44
Joined: Sun Mar 21, 2004 12:18 pm
Location: Stockton California
Contact:

Re: System.UnauthorizedAccessException

Post by dprothero » Wed Mar 10, 2010 6:01 pm

I guess another option could be some kind of semaphore (again, maybe a record in a db table) that tells the system a vault operation is in progress. Then, before performing a vault operation, the ASP.NET would check for this semaphore. If it existed, it would wait until it disappeared. Once it was gone, it'd create the semaphore to halt anyone else, perform the operation, and then clear the semaphore.

Might not be as much dev effort though, but I could see that semaphore getting orphaned, so we'd want an easy way to reset it.

Does it sound like we're on the right track here in terms of just trying to avoid multi-user collisions?

David

Beth
Posts: 8550
Joined: Wed Jun 21, 2006 8:24 pm
Location: SourceGear
Contact:

Re: System.UnauthorizedAccessException

Post by Beth » Thu Mar 11, 2010 2:50 pm

A semaphore could work (), or you might also look a using a named, system mutex - http://msdn.microsoft.com/en-us/library ... 85%29.aspx.
Beth Kieler
SourceGear Technical Support

Post Reply