Hi,
The SavePrivateObject method of the PersistenceBroker class implements the command "PCSQLHits.Increment()". It is command is of type PerformanceCounter. However, when the command PCSQLHits.Increment() is executed, the variable PCSQLHits has value nothing and the object not is saved. What must be make for resolve this is problem?
Thanks,
Meiriana.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If PCSQLHits is nothing it usually indicates you do not have permissions to update the performance counters on your system. You can check by stepping through PersistenceBroker.InitPerformanceCounters and looking at the exception message
This is why all performance counter updates are contained within try/catch blocks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
At execution of the application the PersistenceBroker.InitPerformanceCounters not is executed? I have to give any command for this is method be executed?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I called the PersistenceBroker.Init() method in the PageLoad of the aspx and yet not obtained save the object. At execution of the application the PersistenceBroker.InitPerformanceCounters yet not is executed.
Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In the load method of the application the following code is executed:
Dim persBroker As PersistenceBroker = New PersistenceBroker
persBroker.Init(System.Configuration.ConfigurationSettings.AppSettings("XMLInit"), True)
In the class CPersistenceBroker the init method is called:
Public Sub Init(ByVal xmlFile As String, ByVal useCache As Boolean)
To click in the save button ocurred the following execution:
object.save(true)
In the class CPersistenceObject the save method is called:
Public Overridable Sub Save(ByVal checkAssociationsRecursively As Boolean) Implements IPersistentObject.save
In the class CPersistenceBroker the SaveObject and SavePrivateObject methods are called:
Public Sub SaveObject(ByVal obj As IPersistableObject)
Private Sub SavePrivateObject(ByVal obj As IPersistableObject, ByVal conn As IConnection)
Inside of SavePrivateObject method the following code is executed:
Also, when you first call persBroker.Init execution should proceed to GetOrSetPBInstance (in ModPersistenceBrokerSingleton). The first time through (and only the first time) you should hit the InitPerformanceCounters call.
I thought in call GetOrSetPBInstance method, however this method is declared as Friend, and i cannot it call in my application and only in the AtomsFramework project. Exists an form for call this method? I want see it been executed.
Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry if I was a little unclear. The statement "when you first call persBroker.Init execution should proceed to GetOrSetPBInstance" is meant to indicate that the execution will call the GetOrSetPBInstance method. It's not meant to be callable from your application.
If you want a reference to the persistence broker you should be using the GetPersistenceBrokerInstance method.
In the VStudio IDE just put a breakpoint on the GetOrSetPBInstance method and run your application and the debugger will stop there automatically.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Really, the GetOrSetPBInstance is called, however the InitPerformanceCounters method not is called. For i understand the PCSQLHits variable is initialize this is method. As it's not called, the PCSQLHits variable have nothing value. I called the method init in the PAgeLoad method of the application.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I don't know what else I can tell you. The only thing I can think of is that maybe the persistence broker is being initialised elsewhere (maybe in application start?) and that you're breakpoint is only firing on the second or third time into the init routine.
As you can see from the code, the method should be fired on the first time into the routine, but never again after that.
Also, the code works here without any problem. I assume you've looked into the permission issues with ASP.NET (as per a previous post).
Maybe you could add some console/debug output to the code in GetOrSetPBInstance to try and see if there are other calls being made that you aren't aware of.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
The SavePrivateObject method of the PersistenceBroker class implements the command "PCSQLHits.Increment()". It is command is of type PerformanceCounter. However, when the command PCSQLHits.Increment() is executed, the variable PCSQLHits has value nothing and the object not is saved. What must be make for resolve this is problem?
Thanks,
Meiriana.
If PCSQLHits is nothing it usually indicates you do not have permissions to update the performance counters on your system. You can check by stepping through PersistenceBroker.InitPerformanceCounters and looking at the exception message
This is why all performance counter updates are contained within try/catch blocks.
At execution of the application the PersistenceBroker.InitPerformanceCounters not is executed? I have to give any command for this is method be executed?
It should be called when the PersistenceBroker.Init() method is called.
If .Init() is not explicitly called, it is done implicitly the first time you attempt to retrieve or persist an object.
I called the PersistenceBroker.Init() method in the PageLoad of the aspx and yet not obtained save the object. At execution of the application the PersistenceBroker.InitPerformanceCounters yet not is executed.
Thanks.
I'm not really sure what's going on. Are you getting any exceptions being thrown?
I'm guessing that the init method is failing before the performance counters get initialised.
Hi,
I go make an resume description of the execution:
In the load method of the application the following code is executed:
Dim persBroker As PersistenceBroker = New PersistenceBroker
persBroker.Init(System.Configuration.ConfigurationSettings.AppSettings("XMLInit"), True)
In the class CPersistenceBroker the init method is called:
Public Sub Init(ByVal xmlFile As String, ByVal useCache As Boolean)
To click in the save button ocurred the following execution:
object.save(true)
In the class CPersistenceObject the save method is called:
Public Overridable Sub Save(ByVal checkAssociationsRecursively As Boolean) Implements IPersistentObject.save
In the class CPersistenceBroker the SaveObject and SavePrivateObject methods are called:
Public Sub SaveObject(ByVal obj As IPersistableObject)
Private Sub SavePrivateObject(ByVal obj As IPersistableObject, ByVal conn As IConnection)
Inside of SavePrivateObject method the following code is executed:
Try
statement = cm.GetInsertSqlFor(obj)
conn.ProcessStatement(statement)
usedInsert = True
PCSQLHits.Increment()
PCUpdates.Increment()
In this moment, the PCSQLHits variable is nothing and the execution go to catch:
Catch
Debug.WriteLine("Couldn't insert object in unknown state, trying to update...")
Then, the execution go to try code following, therefore the save failed and the update will be executed:
Try
statement = cm.GetUpdateSqlFor(obj)
conn.ProcessStatement(statement)
usedInsert = False
PCSQLHits.Increment()
PCUpdates.Increment()
As PCSQLHits is nothing the execution failed and go to catch
Catch
Debug.WriteLine("Couldn't update object in unknown state, throwing initial exception")
The message error is: "No records were affected by the update"
PS: The method InitPerformanceCounters never is called in the execution.
Thanks,
Meiriana.
OK. I bit more information is useful...
In SavePrivateObject the code should have been
Try
statement = cm.GetInsertSqlFor(obj)
conn.ProcessStatement(statement)
usedInsert = True
Try
PCSQLHits.Increment()
PCUpdates.Increment()
Catch
End Try
...
I'll fix that.
Also, when you first call persBroker.Init execution should proceed to GetOrSetPBInstance (in ModPersistenceBrokerSingleton). The first time through (and only the first time) you should hit the InitPerformanceCounters call.
If there is a problem you should see a trace message indicating the performance counters couldn't be created. If this happens see http://objectsharp.com/Blogs/bruce/archive/2003/12/05/222.aspx for some steps to take to fix things.
Hi,
I thought in call GetOrSetPBInstance method, however this method is declared as Friend, and i cannot it call in my application and only in the AtomsFramework project. Exists an form for call this method? I want see it been executed.
Thanks.
Sorry if I was a little unclear. The statement "when you first call persBroker.Init execution should proceed to GetOrSetPBInstance" is meant to indicate that the execution will call the GetOrSetPBInstance method. It's not meant to be callable from your application.
If you want a reference to the persistence broker you should be using the GetPersistenceBrokerInstance method.
In the VStudio IDE just put a breakpoint on the GetOrSetPBInstance method and run your application and the debugger will stop there automatically.
Ok,
Really, the GetOrSetPBInstance is called, however the InitPerformanceCounters method not is called. For i understand the PCSQLHits variable is initialize this is method. As it's not called, the PCSQLHits variable have nothing value. I called the method init in the PAgeLoad method of the application.
I don't know what else I can tell you. The only thing I can think of is that maybe the persistence broker is being initialised elsewhere (maybe in application start?) and that you're breakpoint is only firing on the second or third time into the init routine.
As you can see from the code, the method should be fired on the first time into the routine, but never again after that.
Also, the code works here without any problem. I assume you've looked into the permission issues with ASP.NET (as per a previous post).
Maybe you could add some console/debug output to the code in GetOrSetPBInstance to try and see if there are other calls being made that you aren't aware of.