I am playing with the Microsoft Outlook View control, trying to understand its capabilities, but I'm not getting very far. It shows up at design time, but at runtime it just gives an "E_CLASSNOTREG" exception. How do I find out what class it is complaining about?
I just created a winform project, added the control to the toolbox, and dragged it to the form. I see my outlook inbox at design time. It adds the following code:
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.axViewCtl1 = new AxMicrosoft.Office.Interop.OutlookViewCtl.AxViewCtl();
((System.ComponentModel.ISupportInitialize)(this.axViewCtl1)).BeginInit();
this.SuspendLayout();
//
// axViewCtl1
//
this.axViewCtl1.Enabled = true;
this.axViewCtl1.Location = new System.Drawing.Point(384, 184);
this.axViewCtl1.Name = "axViewCtl1";
this.axViewCtl1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axViewCtl1.OcxState")));
this.axViewCtl1.Size = new System.Drawing.Size(192, 192);
this.axViewCtl1.TabIndex = 0;
//
// Form1
//
this.ClientSize = new System.Drawing.Size(1093, 633);
this.Controls.Add(this.axViewCtl1);
this.Name = "Form1";
((System.ComponentModel.ISupportInitialize)(this.axViewCtl1)).EndInit();
this.ResumeLayout(false);
}
Then I run it and it dies on me with:
System.Runtime.InteropServices.COMException occurred
Message="Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))"
Source="System.Windows.Forms"
ErrorCode=-2147221164
StackTrace:
at System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(Guid& clsid, Object punkOuter, Int32 context, Guid& iid)
at System.Windows.Forms.AxHost.CreateWithoutLicense(Guid clsid)
at System.Windows.Forms.AxHost.CreateWithLicense(String license, Guid clsid)
at System.Windows.Forms.AxHost.CreateInstanceCore(Guid clsid)
at System.Windows.Forms.AxHost.CreateInstance()
at System.Windows.Forms.AxHost.GetOcxCreate()
at System.Windows.Forms.AxHost.TransitionUpTo(Int32 state)
at System.Windows.Forms.AxHost.CreateHandle()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.AxHost.EndInit()
at Sample.OutlookForm.Form1.InitializeComponent() in D:\source\tests\OutlookView\Sample.OutlookForm\Form1.Designer.cs:line 50
InnerException:
...the exception is at EndInit().
Also, the other odd thing is that every time I click on the control in the designer, visual studio freezes for a period, sometimes for as short as 30 seconds, other times I have to kill the outlook task to get VS to respond.
I am running VS 2008 with latest patches/SP, on Windows 7 x64, and I have office 2007 with all latest patches and service packs installed.
Why would this work for me at design time, but fail at run time? And how can I find out what it is looking for that is not registered?