• Subject: Re: Unable to cast object of type 'System.__ComObject' to type 'Microsoft.Office.Interop.Outlook.ApplicationClass'
  • Author: Dmitry Streblechenko
  • Date: 16 Jun
  • References: 1
Why would you create an instance of the Outlook.Aplication object if you can
get it drectly from Outlook?
Besides being easier, that instance of the Outlook.Aplication object will
not be subject to the security prompts.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"John Yovas" <john@ez-data_NOSPAM.com> wrote in message
news:OiVskB%23zIHA.4912@TK2MSFTNGP03.phx.gbl...
> We get this error only in one of our users PC with office 2003 we tried re
> Reinstalling the Office 2003 Primary InterOp Assemblies also. Why should
> this happen in only one users desktop when we have this add-in running on
> 100 of other workstation ?
>
> Microsoft.Office.Interop.Outlook.Application oApplication = null;
>
> try
>
> {
>
> comboBox_Folder.Items.Clear();
>
> Type oType = Type.GetTypeFromProgID("Outlook.Application");
>
> if (oType != null)
>
> oApplication =
> (Microsoft.Office.Interop.Outlook.Application)Activator.CreateInstance(oType);
>
>
>
> Unable to cast object of type 'System.__ComObject' to type
> 'Microsoft.Office.Interop.Outlook.ApplicationClass'.
> at
> System.Runtime.Remoting.RemotingServices.AllocateUninitializedObject(RuntimeType
> objectType)
> at
> System.Runtime.Remoting.RemotingServices.AllocateUninitializedObject(Type
> objectType)
> at
> System.Runtime.Remoting.Activation.ActivationServices.CreateInstance(Type
> serverType)
> at
> System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(Type
> serverType, Object[] props, Boolean bNewObj)
> at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean
> publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle&
> ctor, Boolean& bNeedSecurityCheck)
> at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean
> fillCache)
> at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean
> skipVisibilityChecks, Boolean fillCache)
> at System.Activator.CreateInstance(Type type, Boolean nonPublic)
>
> TIA
> John
>
16 JunUnable to cast object of type 'System.__ComObject' to type 'Microsoft.Office.....John Yovas
16 Jun|- Re: Unable to cast object of type 'System.__ComObject' to type 'Microsoft.Off....Dmitry Streblechenko
12 Sep\ RE: Unable to cast object of type 'System.__ComObject' to type 'Micros.hops10
All times are in (US) Eastern Daylight Time (GMT -4:00)