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

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:

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

'*** 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
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

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
<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
Function GetWorkItemDetail(ByRef intDailyStatID As Short) As

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 _
Statistics.IManageStats.DeleteStatSheetWorkItem ....
Public Function GetWorkItems() As ADODB.Recordset _
Statistics.IManageStats.GetWorkItems ....
End Class

End Namespace
mminto's Profile:
View this thread:

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

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

This discussion thread is closed

Replies have been disabled for this discussion.