Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / April 2004

Tip: Looking for answers? Try searching our database.

InvalidCastException calling Outlook

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeff Curren - 16 Apr 2004 22:36 GMT
Additional information: QueryInterface for interface Outlook._Application
failed.

I'm running:
golApp = new Outlook.ApplicationClass();

gnspNameSpace = golApp.GetNamespace("MAPI");

on Windows XP with Outlook 2002.

I've completed the steps described by KB Q309336 and downloaded the Office
Interop libraries from microsoft.  The Office dlls are referencing the
downloaded libraries but for some reason the Microsoft.Office.Core library
is still referenced from the original location
(c:\windows\assembly\gac\office\7.0.3300.0__b03f5f7f11d50a3a\office.dll)

I assume the next problem I have to solve to make this work is to coerce the
Microsoft.Office.Core to load from the downloaded libraries but I can't see
how to do that yet.

Any suggestions would be appreciated.

Thanks,
Jeff
Stuart Fujitani - 17 Apr 2004 06:06 GMT
Jeff

Ensure that the Office XP PIA's are installed into the GAC.  Microsoft has strongly named the PIA's and marked them as the primary interop assemblies.  This ensures that Office objects can be shared between different applications using the same identity.
Jeff Curren - 18 Apr 2004 13:48 GMT
Thanks for the reply Stuart. I had already registered the PIAs in the GAC as
instructed by the download readme file.

I'm not sure how many of these are necessary to create an
Outlook.ApplicationClass, but my GAC shows the following all pointing to the
PIA folder:

Microsoft.Office.Interop.Outlook
Office
stdole

Here is the entire code my my project:
using System;

using Microsoft.Office.Interop.Outlook;

namespace OutlookTest

{

class Class1

{

[STAThread]

static void Main(string[] args)

{

Microsoft.Office.Interop.Outlook.Application golApp;

Microsoft.Office.Interop.Outlook.NameSpace gnspNameSpace;

golApp = new Microsoft.Office.Interop.Outlook.ApplicationClass();

gnspNameSpace = golApp.GetNamespace("MAPI");   // Exception thrown here

Console.WriteLine("Success");

}

}

}

> Jeff,
>
> Ensure that the Office XP PIA's are installed into the GAC.  Microsoft has strongly named the PIA's and marked them as the primary interop assemblies.
This ensures that Office objects can be shared between different
applications using the same identity.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.