By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,267 Members | 1,861 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,267 IT Pros & Developers. It's quick & easy.

Unable to cast COM object of type 'System.__ComObject' to interface type

P: n/a

[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(intStatWorkI temID)

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.

<Assembly: ApplicationName("IPB Business Services")>
<Assembly: ApplicationActivation(ActivationOption.Server)>
<Assembly: Description("IPB Business Services - Application Component
Services")>
<Assembly: AssemblyKeyFileAttribute("sgMStats.snk")>
<Assembly: ApplicationAccessControl(True)>

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

<ConstructionEnabled( _
[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

Jan 20 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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....mComObject.htm
Jan 20 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.