views:

408

answers:

1

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?

A: 

First a quick question: How did you get the control on the toolbar? Within ActiveX controls?

If so, I'm afraid you can't use it. That control was developed to be used within Outlook, it's not an external control.

There are several third parties controls that you can use to emulate the look and feel of Outlook without resorting to such measures.

Paulo Santos
the Infragistics Schedule controler (http://www.infragistics.com/dotnet/netadvantage/winforms/winschedule.aspx#Overview) is a pretty good one.
jean
I meant "control", sorry.
jean
Are you sure? The help documentation says:"The Microsoft® Outlook® View Control is primarily designed to be used in an HTML page, such as an Outlook folder home page. " ... "You can also add the Outlook View Control to a custom form in Microsoft Visual Basic® or Visual Basic for Applications and set the properties of the control programmatically."I wouldn't mind using a 3rd party control, but do any provide the Exchange communication layer?
Will I Am
And yes, i added it to the toolbox as a COM/ActiveX control (Choose items/COM Components/check Microsoft Office Outlook View Control) (And it shows up fine at design time, just not at run time.
Will I Am
Will - did you get anywhere with this ? We are having the same issue on x64 machines, and can't find any resolution...
Matt
Nope, unfortunately not, and I did give up on it for now, I may revisit it later.
Will I Am