|
IT Support
Posts: 12
Joined: 2016-08-19
|
Hello,
In my OnSendMessage event method, I am trying to reference a form that I've created. Everything works fine, but towards the end I keep getting an exception when I check my logs "Object reference not set to an instance of an object. "
On checking further, I added a watch to all my variables and controls in the below piece of code.
private void AddinModule_OnSendMessage(object sender, ADXSendMessageEventArgs e)
{
var curr_form = adxOlFormsRequestNewContract.GetCurrentForm() as RequestNewContractOLForm;
curr_form.btnDone.Enabled = false;
curr_form.btnCancel.Enabled = false;
}
}
In my watch window, I see the button "btnDone" show
"error: The name 'btnDone' does not exist in the current context"
in the column "Value."
How I can I fix this to stop getting the "Object reference not set to an instance of an object. " error.
Thanks |
|
Posted 12 May, 2017 09:07:22
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 15572
Joined: 2006-05-11
|
Hello,
I would try using GetForm() instead of GetCurrentForm(); see section Outlook form region's instancing at https://www.add-in-express.com/docs/net-outlook-forms.php#instncing.
In what event do you send this message? Can it be that the window, in which your form is shown, becomes closed by the moment you process the message?
Regards from Belarus (GMT+3),
Andrei Smolin
Add-in Express Team Leader |
|
Posted 12 May, 2017 09:29:19
|
|
Top
|
|
IT Support
Posts: 12
Joined: 2016-08-19
|
Hello,
Thanks for the quick reply!
Andrei Smolin writes:
In what event do you send this message? Can it be that the window, in which your form is shown, becomes closed by the moment you process the message?
The form is a part of the inspector. (Compose mail window)
Clicking on the done button on the form, the 'send message' is called.
Am I doing something wrong here? |
|
Posted 12 May, 2017 10:07:01
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 15572
Joined: 2006-05-11
|
IT Support writes:
Clicking on the done button on the form
Does clicking this button close the inspector window? Or deactivates the inspector window in any other way?
Regards from Belarus (GMT+3),
Andrei Smolin
Add-in Express Team Leader |
|
Posted 12 May, 2017 10:15:27
|
|
Top
|
|
IT Support
Posts: 12
Joined: 2016-08-19
|
Andrei Smolin writes:
Does clicking this button close the inspector window? Or deactivates the inspector window in any other way?
private void btnDone_Click(object sender, EventArgs e)
{
CurrentInstance.SendMessage(CurrentInstance.MESSAGE_FILEDOWNLOAD);
}
There's only this line of code on the button click event. |
|
Posted 12 May, 2017 10:21:49
|
|
Top
|
|
Andrei Smolin
Add-in Express team
Posts: 15572
Joined: 2006-05-11
|
IT Support writes:
In my watch window, I see the button "btnDone" show "error: The name 'btnDone' does not exist in the current context"
This should be 'curr_form.btnDone', not 'btnDone': the latter doesn't exist in the context of the add-in module.
Have a nice weekend.
Regards from Belarus (GMT+3),
Andrei Smolin
Add-in Express Team Leader |
|
Posted 12 May, 2017 10:36:30
|
|
Top
|
|