PC Review


Reply
Thread Tools Rate Thread

Can not cast from type System.__ComObject to type Outlook.ApplicationClass an new Outlook.Application

 
 
Me
Guest
Posts: n/a
 
      19th Jun 2004
This is my problem,

Using some code from Paul Reynolds I found at www.ftponline.com (VSM
Archives) i'm trying to make a program interact with different versions of
outlook. Right now i'm only testing on a outlook 2002 version but the
following occurs.

The detetcion of the installed version of outlook works fine. But when a
version of it is beeing inisialized (new Outlook.ApplicaionClass) I get the
following error:
Unable to cast object of type System.__ComObject to type
Outlook.ApplicationClass

Here is a snapshot of the code:

Private m_olApp As Outlook.ApplicationClass = Nothing

Private m_olNS As Outlook.NameSpace = Nothing

Private m_olExplorers As Outlook.Explorers = Nothing

Private m_olInspectors As Outlook.Inspectors = Nothing

Private m_olExplorer As Outlook.ExplorerClass = Nothing

Private m_olInspector As Outlook.InspectorClass = Nothing

Public Sub New()

MyBase.New()

End Sub

Public Overrides Sub InitOutlook()

m_olApp = New Outlook.ApplicationClass 'Create the outlook app window <=
THE ERROR OCCURS HERE

m_olNS = m_olApp.GetNamespace(MAPI_NS) 'Get access to MAPI namespace

m_olNS.Logon(String.Empty, String.Empty, False, False) 'Use current outlook
session

'Get our line into the explorers and inspectors so that we can properly
detect shutdown

m_olExplorers = m_olApp.Explorers

m_olInspectors = m_olApp.Inspectors

'Type conversion required due to "ambiguous name" issue

m_olExplorer = CType(m_olApp.ActiveExplorer, Outlook.ExplorerClass)


The strange thing is... The first time a ran the sample programm it worked
fine. Now when i'm trying to run it "out of the box" it does not work
anymore. Any ideas what could cause this problem?

Thanks in advance for any help

Bart Seresia


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to cast object of type 'System.__ComObject' to type 'Microsoft.Office.Interop.Outlook.ApplicationClass' John Yovas Microsoft Outlook Program Addins 2 12th Sep 2008 04:23 PM
Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Outlook.ContactItem'. Dhananjay Microsoft Outlook VBA Programming 3 13th Oct 2007 07:56 AM
RE: Unable to cast COM object of type 'System.__ComObject' to interfac =?Utf-8?B?U0c=?= Microsoft Dot NET 0 20th Jan 2006 02:27 PM
Unable to cast COM object of type 'System.__ComObject' =?Utf-8?B?U3RldmUgV2lsa2luc29u?= Microsoft Dot NET Framework 0 13th Jan 2006 01:40 PM
Unable to cast object of type System.__ComObject Tony Microsoft C# .NET 1 29th Oct 2004 02:58 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:43 PM.