When I click Tools|Options here's what happens:
1. The following event handler executes:
void ThisApplication_OptionsPagesAdd(Outlook.PropertyPages pages)
{
pages.Add(new ViewPoint.PropertyTab(), "");
}
2. bool m_Dirty = false;
OK, class is obviously initializing...
3. Then InitializeComponent();
OK, class is obviously initializing...
But then, that's it! No call into the TabCaption method as I would expect to
get the tab caption for the property page. And the tab doesn't appear! I
have no idea what I'm doing wrong. I copied this code straight out of Visual
Studio Tools for Office by Eric Carter and Eric Lippert, but I just can't
get this to work!
Thanks for your help!
- Joseph Geretz -
public partial class PropertyTab : UserControl, Outlook.PropertyPage
{
const int C_CaptionDispID = -518;
bool m_Dirty = false;
public PropertyTab()
{
InitializeComponent();
}
void Outlook.PropertyPage.Apply()
{
}
void Outlook.PropertyPage.GetPageInfo(ref string helpFile, ref int
helpContext)
{
}
bool Outlook.PropertyPage.Dirty
{
get
{
return m_Dirty;
}
}
[DispId(C_CaptionDispID)]
public string TabCaption
{
get
{
return "ViewPoint";
}
}
}
Joseph Geretz - 24 May 2006 00:14 GMT
I've tracked this down to an exception on the following line of code:
pages.Add(new ViewPoint.PropertyTab(), "");
Here's the error:
System.Runtime.InteropServices.COMException was caught
Message="The operation failed."
Source="Microsoft Office Outlook"
ErrorCode=-1802485758
StackTrace:
at Microsoft.Office.Interop.Outlook.PropertyPages.Add(Object Page,
String Title)
at
ViewPoint.ThisApplication.ThisApplication_OptionsPagesAdd(PropertyPages
pages) in C:\Documents and Settings\Administrator.INTERNAL\My
Documents\Visual Studio
2005\Projects\ViewPoint\ViewPoint\ThisApplication.cs:line 51
Not much information. Where do I go from here?
Thanks for your help.
- Joe Geretz -
> When I click Tools|Options here's what happens:
>
[quoted text clipped - 57 lines]
> }
> }
Joseph Geretz - 24 May 2006 00:47 GMT
Another thing I notice is that in the following event:
void ThisApplication_OptionsPagesAdd(Outlook.PropertyPages pages)
{
pages.Add(new ViewPoint.PropertyTab(), "");
}
the pages parameter is passed in with a count of 0. Is this correct? Does
this reflect the number of custom property pages (in which case 0 is
probably correct) or should it reflect the number of 'built in' property
pages, in which case 0 would not be the expected value?
Thanks for your help,
- Joe Geretz -
> I've tracked this down to an exception on the following line of code:
>
[quoted text clipped - 82 lines]
>> }
>> }
Joseph Geretz - 26 May 2006 03:43 GMT
Here's the problem:
VSTO projects require the following attribute preceding the UserControl
class definition:
[ComVisible(true)]
'Be nice if the book I'm working from, Visual Studio Tools for Office by
Carter and Lippert, would have gotten this right. You'd think that two
authors collaborating together could turn out accurate documentation! I
guess they couldn't be bothered to actually write the sample code - easier
to copy and paste it from the last book they wrote on Extensibility AddIns.
Grrrrr - cost me 4 days :-(
Hope this helps someone else out there with the same problem.
- Joe Geretz -
> Another thing I notice is that in the following event:
>
[quoted text clipped - 98 lines]
>>> }
>>> }