Unable to cast COM object of type "System.__ComObject" to interface type
am 20.01.2006 03:21:24 von mminto
[ERROR MESSAGE:]
Unable to cast COM object of type 'System.__ComObject' to interface
type 'Manage.Statistics.IManageStats'. This operation failed because
the QueryInterface call on the COM component for the interface with IID
'{4C2875B5-3265-306B-9C74-1BEC98986B1A}' failed due to the following
error: Error loading type library/DLL. (Exception from HRESULT:
0x80029C4A (TYPE_E_CANTLOADLIBRARY)).
The client is calling a method shown below (exposed by a custom written
COM+ Application):
dim blnResult as Boolean
dim m_ManageStats as Manage.Statistics.IManageStats = new
Manage.Statistics.ManageStats
'*** Exception thrown by the following statment ***
blnResult = m_ManageStats.DeleteStatSheetWorkItem(intStatWorkItemID)
NB. The call should flow as shown:
--------------------------------------
[Client App]<-->[Application Proxy]<-->[COM+ Application]<-->[SQL
Server 2000 DBMS]<-->[Database Stored Procedure]
The interfaces etc are summarised below.
N.B. Some of the exposed methods in the same interface below work as
expected.
ALSO The client works fine when calling methods on the same host as
COM+ Application.
Below is the header for the 'ManageStats' COM+ Application
After Building the ManageStats.dll it is installed and registered as
followed:
Regsvcs.exe ManageStats.dll 'Installs and registers the COM+
Application called "IPB Business Services"
GacUtil.exe /i ManageStats.dll 'Intalls the assembly in the Global
Assembly Cache - Doesn't work without this.
Services")>
Namespace Statistics
Public Interface IManageStats
Function DeleteStatSheetWorkItem(ByRef intStatWorkItemID As Short)
As Boolean
Function GetWorkItems() As ADODB.Recordset
Function GetSubmittedSheets(ByRef sUserName As String) As
ADODB.Recordset
Function GetWorkItemDetail(ByRef intDailyStatID As Short) As
ADODB.Recordset
End Interface
[Default]:="DBServer=, Database=, DBUserName=, DBPassword="), _
ComponentAccessControl(True), _
Transaction(TransactionOption.Required)> _
Public Class ManageStats
Inherits ServicedComponent
Implements Statistics.IManageStats
Public Function DeleteStatSheetWorkItem(ByRef intStatWorkItemID As
Short) _
As Boolean _
Implements
Statistics.IManageStats.DeleteStatSheetWorkItem ....
Public Function GetWorkItems() As ADODB.Recordset _
Implements
Statistics.IManageStats.GetWorkItems ....
End Class
End Namespace
--
mminto
------------------------------------------------------------ ------------
mminto's Profile: http://www.hightechtalks.com/m771
View this thread: http://www.hightechtalks.com/t2337796
RE: Unable to cast COM object of type "System.__ComObject" to interfac
am 20.01.2006 15:27:04 von sg
This looks like an error I've encountered before. There's a writeup specific
to our software here, but the issue I think is the same - try using the
System.Activator class to instantiate instead of the new keyword:
Type t = Type.GetTypeFromProgID("libname.classname");
System.Object obj = Activator.CreateInstance(t);
IMyInterface myclass = obj as IMyInterface;
See the writeup at:
http://edndoc.esri.com/arcobjects/9.1/default.asp?url=/arcob jects/9.1/ArcGISDevHelp/DevelopmentEnvs/DotNet/SystemComObje ct.htm
Re: Unable to cast COM object
am 29.10.2007 18:16:44 von MR. Arnold
"Simon Pollock" wrote in message
news:Ov8xGBkGIHA.4712@TK2MSFTNGP04.phx.gbl...
What's a tlb?
COM Type Libraries are binary files with .tlb extension. Usually this files
contain information about COM interfaces and components. To use this
information, type library must be registered on target system.
http://www.google.com/search?hl=en&q=what+is+a+type+library+ file&btnG=Google+Search
RE: Unable to cast COM object
am 30.10.2007 06:19:38 von jialge
Hello Simon
From your post, my understanding on this issue is: you want to know how to
fix the issue that the automation client throws exception: "Unable to cast
COM object of type¡" in the target machine, but not in development
machine. If I'm off base, please feel free to let me know.
According to your description, the automation client runs well in the
development environment. However, when it is run on another computer with
Access 2007, it throws the exception. Therefore, my guess is that the
target machine is not installed with Office 2007 PIA (Primary Interop
Assembly). Office 2007 PIA (.NET support of Office) is a group of
assemblies that helps to interoperate between .NET applications and Office
COM objects. If .NET support of Office is not selected when you are
installing Office 2007 in the target machine, the exception "Unable to cast
COM object of type¡" might be thrown in Office automation clients. To
install Office 2007 PIA, please go to the page:
http://www.microsoft.com/downloads/details.aspx?familyid=59d aebaa-bed4-4282-
a28c-b864d8bfa513&displaylang=en and install it in the target machine. Then
run your application again to see if the issue is resolved.
If the suggestion above could not help, would you let me know the type of
your Office automation client? Is it an Office COM Add-in? Is it a VSTO
one? Would you try {} catch the exception in code, print the call stack,
and let me know the line of code that throws the exception? I am looking
forward to your reply.
Sincerely,
Jialiang Ge (jialge@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
==================================================
For MSDN subscribers whose posts are left unanswered, please check this
document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/de fault.aspx#notif
ications. If you are using Outlook Express/Windows Mail, please make sure
you clear the check box "Tools/Options/Read: Get 300 headers at a time" to
see your reply promptly.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx .
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
RE: Unable to cast COM object
am 01.11.2007 03:25:29 von jialge
Hi Simon,
Would you mind letting me know the result of the suggestions? If you need
further assistance, feel free to let me know. I will be more than happy to
be of assistance.
Have a great day!
Sincerely,
Jialiang Ge (jialge@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.