AV when accessing UserSession
Re: AV when accessing UserSession
FYI when I switch off MADShi, I get all the information I need when “procedure TIWServerController.IWServerControllerBaseException(AApplication: TIWApplication; AException: Exception; var Handled: Boolean);” is called.
Is there any way I can hook this into the MADShi “AddCommandLineHeaderInfo” procedure?
Is there any way I can hook this into the MADShi “AddCommandLineHeaderInfo” procedure?
Re: AV when accessing UserSession
How do you get all the information you need? By using the "function UserSession: TIWUserSession" function you posted earlier? Or by using the "TIWServerController.IWServerControllerBaseException()" parameters?
And when the handler is called which madIWSupport.pas registers through "TIWServerControllerBase.RegisterExceptionCallback()", you don't get the same information?
And when the handler is called which madIWSupport.pas registers through "TIWServerControllerBase.RegisterExceptionCallback()", you don't get the same information?
Re: AV when accessing UserSession
... by using TIWServerController.IWServerControllerBaseException(AApplication: TIWApplication; AException: Exception; var Handled: Boolean) of which the AApplication is the reference to the logged in user's UserSession.madshi wrote:How do you get all the information you need? By using the "function UserSession: TIWUserSession" function you posted earlier? Or by using the "TIWServerController.IWServerControllerBaseException()" parameters?
"TIWServerController.IWServerControllerBaseException()" is only called when my app is compiled without MADshi. In any event, I do not have "TIWServerControllerBase.RegisterExceptionCallback()" in my code and did not find any reference to itmadshi wrote:And when the handler is called which madIWSupport.pas registers through "TIWServerControllerBase.RegisterExceptionCallback()", you don't get the same information?
Re: AV when accessing UserSession
Are you using the madIWSupport.pas/dfm files from my attachment zip to this thread a couple of posts ago? It has an "{$define useIWExceptionCallback}". If that define is set, it should use "TIWServerControllerBase.RegisterExceptionCallback()" to officially register an exception callback. Otherwise, it uses my old hook solution.
In both cases, you should get access to AApplication though "exceptIntf.RelatedObject".
In both cases, you should get access to AApplication though "exceptIntf.RelatedObject".
Re: AV when accessing UserSession
Sorry! I was confusing myself...
I did not have madIWSupport from the earlier post built into that last test- I now d.
AApplication is being assigned but with the code below, line " exceptIntf.BugReportHeader['User #'] := UserSession.gv_UID;" generates an AV. When I evaluate UserSession.gv_UID before the AV is generated, it returns a null string - by that I mean empty string.
I did not have madIWSupport from the earlier post built into that last test- I now d.
AApplication is being assigned but with the code below, line " exceptIntf.BugReportHeader['User #'] := UserSession.gv_UID;" generates an AV. When I evaluate UserSession.gv_UID before the AV is generated, it returns a null string - by that I mean empty string.
Code: Select all
procedure TIWUserSession.IWUserSessionBaseCreate(Sender: TObject);
begin
gv_UID := 'User';
gv_SID := 'Site';
end;
{$IFDEF madExcept}
procedure AddCommandLineHeaderInfo(const exceptIntf: IMEException; var handled: boolean);
begin
exceptIntf.BugReportHeader['Product'] := 'Test';
exceptIntf.BugReportHeader['User #'] := UserSession.gv_UID;
exceptIntf.BugReportHeader['Site ID'] := UserSession.gv_SID;
end;
initialization
RegisterExceptionHandler(AddCommandLineHeaderInfo, stDontSync);
{$ENDIF}
Re: AV when accessing UserSession
Did you try "exceptIntf.RelatedObject", as I suggested in my previous comment?
Re: AV when accessing UserSession
I could not access AApplication or UserSession through "exceptIntf.RelatedObject"
Re: AV when accessing UserSession
What happened when you tried? Was RelatedObject "nil"? Or did you get a crash? How exactly did your code using RelatedObject look like?
Re: AV when accessing UserSession
I may not be calling the RelatedObject correctly to expose AApplication but I could not find any reference to it in RelatedObject so I could not build the app and when I put a break point at exceptIntf.BugReportHeader['Product'] := 'Test'; i could not find any reference to AApplication or a TIWApplication
Re: AV when accessing UserSession
Try this:
Code: Select all
if Assigned(exceptIntf.RelatedObject) and (exceptIntf.RelatedObject is TIWApplication) then
with TIWApplication(exceptIntf.RelatedObject) do
Re: AV when accessing UserSession
Your suggestion did not provide access to UserSession but it gave me an idea.
I have only tested this with a single session but it should work with multiple sessions. I may need to Lock/Unlock the LSessions list in a critical section - more investigation needed by me.
That said, I have attached a 7Z of the working test project.
Critiques, ripping apart, improvements, suggestion are all welcome.
Thank you for your extreme persistence and extensive help.
I have only tested this with a single session but it should work with multiple sessions. I may need to Lock/Unlock the LSessions list in a critical section - more investigation needed by me.
That said, I have attached a 7Z of the working test project.
Critiques, ripping apart, improvements, suggestion are all welcome.
Thank you for your extreme persistence and extensive help.
Re: AV when accessing UserSession
... went to make a coffee and it dawned on me that I missed your important point in your last post about
Please see the revised project code attached.
Again, thank you.
... now I will make that coffee.
Code: Select all
if Assigned(exceptIntf.RelatedObject) and (exceptIntf.RelatedObject is TIWApplication) then
with TIWApplication(exceptIntf.RelatedObject) do
Again, thank you.
... now I will make that coffee.
Re: AV when accessing UserSession
So all problems solved?
Re: AV when accessing UserSession
It looks like it. Thanks
Re: AV when accessing UserSession
Good to hear. So which of the 2 madIWSupport variants are you using now? The hook variant, or the official callback variant? With the test project, they both seem to do the job. However, the official callback variant seems to show an extra message box, for some reason. I've asked the IW guys about that, but they didn't reply.