473,554 Members | 2,100 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error while invoking the COM+ components developed using .Net (Serviced Components)

Hi,

I just wanted to put down the issue with more detailed information so that
you can help us get to the right Microsoft resource for a solution! Here is
the problem description...

Our intent:
Accept the COM or COM+ class name, function-name and input parameter (fixed
string parameter) as string inputs and execute(invoke) the function at run
time.

Issue:

When the above discussed procedure is tried using the .Net code (pasted
below) we are getting the error: "Cannot load type (<COM ProgID>, <Assembly
Name>, Version=x.x.x.x , Culture=neutral , PublicKeyToken= xxxxxxxxx.". The
process works perfectly when COM/COM+ components (being invoked) are
developed either in VC++ or VB. Error is returned only for the COM+
components developed using .Net (Serviced Components).
Type typ1 = Type.GetTypeFro mProgID(<COM ProgID>);
obj = Activator.Creat eInstance(typ1) ;
Object[] ArrArgs = new Object [0];
typ1.InvokeMemb er(<Interface Method Name>, BindingFlags.In vokeMethod, null,
obj, ArrArgs);

We have also observed that the same component (.Net Serviced component)
works perfectly when invoked from VC++ or late-binding from VB. Code samples
used to test this process in VB and VC++ are pasted at the end of this
email.

What help we need?:

We need the .Net equivalent for the VC++ function code pasted below. This
function must work on all COM/COM+ component developed in any of the
programming languages, eg. VB, VC++ or .Net Serviced components.

VB:

Set obj = CreateObject(<C OM ProgID>)
obj.<Interface Method Name>
Set obj = Nothing

VC++

STDMETHODIMP Invoke( BSTR bsClassName, BSTR bsFunctionName, BSTR bsInpXML,
VARIANT *vOutXML)
{
EXCEPINFO excepInfo;
DISPID dispid_msg;
DISPPARAMS dpDispMsg;
MULTI_QI mqi[1];
mqi[0].pItf = NULL;

IDispatch* pDispApp = NULL;
_variant_t vtResult;

VARIANT
vDispMsg[1];
VariantInit( &vDispMsg[0] );

START_ERROR_LOO KUP
CLSID clsid;

SAFE_CALL( CLSIDFromProgID ( bsClassName, &clsid ) );

mqi[0].pIID = &IID_IUnknow n;
mqi[0].hr = S_OK;

SAFE_CALL ( CoCreateInstanc eEx( clsid, NULL,
CLSCTX_LOCAL_SE RVER, NULL, 1, mqi ) );
SAFE_CALL( mqi[0].pItf->QueryInterface ( IID_IDispatch,
(void**)&pDispA pp ) );

vDispMsg[0].vt = VT_BSTR;
vDispMsg[0].bstrVal = _bstr_t(bsInpXM L).copy();

dpDispMsg.cArgs = 1; //Total no of arguments to be passed

dpDispMsg.cName dArgs = 0;
dpDispMsg.rgvar g = vDispMsg;

SAFE_CALL( pDispApp->GetIDsOfName s( IID_NULL,
&bsFunctionName , 1, LOCALE_USER_DEF AULT, &dispid_msg ) );

//Invoking a MTS method
SAFE_CALL( pDispApp->Invoke(dispid_ msg, IID_NULL,
LOCALE_USER_DEF AULT, DISPATCH_METHOD ,
&dpDispMsg, &vtResult, &excepInfo, NULL ) );

vOutXML->vt = VT_BSTR;
vOutXML->bstrVal = _bstr_t(vtResul t).copy();

if( pDispApp != NULL ) pDispApp->Release();
if( mqi[0].pItf != NULL ) mqi[0].pItf->Release();

VariantClear ( &vDispMsg[0] );

START_ERROR_HAN DLER

if( orchErr.GetErro rCode() == DISP_E_EXCEPTIO N )
orchErr.SetOrch ErrorInfo( excepInfo );

// clearing
if( pDispApp != NULL ) pDispApp->Release();
if( mqi[0].pItf != NULL ) mqi[0].pItf->Release();

VariantClear ( &vDispMsg[0] );

END_ERROR_LOOKU P
return S_OK;
}

Thanks & Regards,
Praveen
Jun 9 '06 #1
4 2942
Hello Praveen,

After reading your message, I build a very simple test project in VS.NET
2005:

Project Type: Class Library

Code:

using System;
using System.Collecti ons.Generic;
using System.Text;
using System.Runtime. InteropServices ;
namespace COMTest
{
[GuidAttribute(" 65EA989D-DFCD-4D36-9E00-A9D928F8B9A2"),
ComVisible(true ),ProgId("COMTe st.Class1")]
public class Class1
{
public string GetHello(string name)
{
return "Hello, " + name;
}
}
}

Adn then strong name it, put the assemly in GAC and register it with
regasm.exe:

Regasm COMtest.DLL

And then, I create a windows form project with following code:
Type typ1 = Type.GetTypeFro mProgID("COMTes t.Class1");

Object obj = Activator.Creat eInstance(typ1) ;
Object[] ArrArgs = new Object [1];

ArrArgs[0] = "Luke";

object r=typ1.InvokeMe mber("GetHello" ,
BindingFlags.In vokeMethod, null, obj, ArrArgs);

MessageBox.Show ((string)r);
This work as expected on my side. So, compare with my test code, is there
any difference from yours? Especially, the ComVisible attribute and
registering with regasm.exe?

Regards,

Luke Zhang
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.)

Jun 12 '06 #2
Hi Luke,

Thanks for your reply.

The sample which you have sent is working for non-servicedcompone nt
application. But, what we are using are ServiceComponen t. It is not working
for me.

The below is sample project which i made based on your sample to convert it
into ServicedCompone nt, when you try to invoke a method in this component
using .NET you will get the same error.
using System;
using System.Collecti ons;
using System.Text;
using System.Runtime. InteropServices ;
using System.Enterpri seServices;

namespace ABCTest
{
/// <summary>
/// Summary description for Class1.
/// </summary>
///
[GuidAttribute(" FA25C241-EE0B-4cec-BE91-30119F116CF2"), ComVisible(true ),
ProgId("ABCTest .Class1")]
public class Class1 : ServicedCompone nt
{
public Class1()
{
//
// TODO: Add constructor logic here
//
}
public string GetHello(string name)
{
return "Hello, " + name ;
}
}
}
Regards,

Praveen.

"Luke Zhang [MSFT]" <lu******@onlin e.microsoft.com > wrote in message
news:UZ******** ******@TK2MSFTN GXA01.phx.gbl.. .
Hello Praveen,

After reading your message, I build a very simple test project in VS.NET
2005:

Project Type: Class Library

Code:

using System;
using System.Collecti ons.Generic;
using System.Text;
using System.Runtime. InteropServices ;
namespace COMTest
{
[GuidAttribute(" 65EA989D-DFCD-4D36-9E00-A9D928F8B9A2"),
ComVisible(true ),ProgId("COMTe st.Class1")]
public class Class1
{
public string GetHello(string name)
{
return "Hello, " + name;
}
}
}

Adn then strong name it, put the assemly in GAC and register it with
regasm.exe:

Regasm COMtest.DLL

And then, I create a windows form project with following code:
Type typ1 = Type.GetTypeFro mProgID("COMTes t.Class1");

Object obj = Activator.Creat eInstance(typ1) ;
Object[] ArrArgs = new Object [1];

ArrArgs[0] = "Luke";

object r=typ1.InvokeMe mber("GetHello" ,
BindingFlags.In vokeMethod, null, obj, ArrArgs);

MessageBox.Show ((string)r);
This work as expected on my side. So, compare with my test code, is there
any difference from yours? Especially, the ComVisible attribute and
registering with regasm.exe?

Regards,

Luke Zhang
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.)

Jun 14 '06 #3
Hello Praveen,

I also test this with servicedcompone nt :

using System;
using System.Collecti ons.Generic;
using System.Text;
using System.Runtime. InteropServices ;
using System.Enterpri seServices;
namespace COMTest
{
[GuidAttribute(" 65EA989D-DFCD-4D36-9E00-A9D928F8B9A2"),
ComVisible(true ),ProgId("COMTe st.Class1")]
public class Class1 : ServicedCompone nt
{
public string GetHello(string name)
{
return "Hello, " + name;
}
}
}

After change the code, I re-compile the whole project, add the assembly in
GAC and register with regasm.exe. (Also generate a tlb file with
regasm.exe). And then, add a COM+ application and add the tlb file as a
components. When I test my client application, it still worked.

Is there any difference between our tests?

Luke Zhang
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.)

Jun 15 '06 #4
Hello Praveen,

Your sample works flawless on my side. I think there are some issues we may
check:

1. I changed the KEYFile to a .snk file generated by sn.exe.
2. When I create the COM+ application, I left all as default value: Create
an empty application->Server application->Interactive user - the current
logged on user ->...

Regards,

Luke Zhang
Microsoft Online Community Lead

=============== =============== =============== =====
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.)

Jun 21 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3243
by: Grant | last post by:
I've cross-posted this in the COM+ group as well - apologies if that's a no-no. But the problem might be caused by either... interop or just plain COMAdmin. ============================================= I've got a VB.NET app that is trying to access the Component Services catalog. The first class method installs a new component at a...
5
5123
by: Kedar Agarkar | last post by:
: This is general query seeking opinions about COM+ Development wherein Server is developed in C# and Client accessing that across machines is also C#. Wish to seek experienced words on issues of COM-.NET interop that is playing major decisive role on both sides and is making decisions complicated only based upon theory.
26
4434
by: Lasse Edsvik | last post by:
Hello I'm trying to build a simple COM+ app in vs.net using C# and i cant register it in component manager..... what more is needed than this: using System; using System.EnterpriseServices;
2
4247
by: John McDonald | last post by:
I am working through tutorials covering developing serviced components. It is appears as though they register correctly using regsvcs and do appear in the MMC snap in. However when I attempt to use them from a project it fails to add the reference with the messange: A reference to xxx could not be added. Converting the type library to a...
3
1260
by: Julia | last post by:
Hi, I have an asp.net app that is using a sql-database localted on a different machine. These two machines are in the same network and there is no firewalls in between. The app is using Serviced Components and are installed in the Component Service. When I try to update the database this error occures: "An error occured while enlisting in...
0
2649
by: SpockMonster | last post by:
Our solution contains multiple projects, such as: 1 Web project 3 library projects that contain Serviced Components 7 library projects that do not contain Servicded Components Long ago, a previous project member created a file chose to name "AssemblyCommonInfo.vb" in the SOlution root, and placed a link to this in every project (except the...
3
299
by: Pete Wittig | last post by:
Hi, I have an assembly with two serviced components. It has been registered using regsvcs.exe and is SOAP enabled. I can see a WSDL link for both components in my browser when I open it to http://localhost/<appname>/default.aspx. However, I want to only display the WSDL link of one of the components. I have tried using the...
2
4655
by: =?Utf-8?B?QkY=?= | last post by:
I am currently working on moving our business objects into COM+ serviced components. But in the process, there are too many changes such ComVisible and serviced component does not support parameterized constructors. So I am thinking whether I should change to use .NET remoting instead. Have anybody else gone through this .NET remoting vs...
8
1712
by: =?ISO-8859-1?Q?Norbert_P=FCrringer?= | last post by:
Hello, I would like to explain, why COM in-process and COM local server are not needed in .NET anymore. Of course there are several .NET techniques how to solve remote communication as successor of .COM remote servers (.NET remoting, WCF communication and web services). But the successor of COM in-process and COM local server is the...
0
7806
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7568
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7891
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6151
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5439
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3568
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3553
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1139
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
845
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.