473,388 Members | 1,256 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

COM component's C++ client works but .net client doesn't?

I have a COM component in ATL, one of its method's IDL define is as the
following:
HRESULT SetValue(long a, [in] long* b,[in]string* c, [in]VARIANT* d,
[out,retval] ConfirmVal e);
here ConfirmVal is a Enum define by IDL.

The VC++ client has no problem to call it by using smart pointer as the
followings:
long a=0;
long b=-1;
CComBSTR c=L"NAME";
d = ICxValuePtr(__uuidof(ICxValue)); //d is another smartpointer, it is a
IDispatch interface in IDL
ConfirmVal e;
ptr->SetValue(a,&b,&c,d,&e)
....

When my C# client calls it as the followings, it throws COMException with
"Unspecified error":
int a=0;
int b=-1;
string c="NAME";
CxValueObject d = new CxValueObject(); //CxValueObject is the class
corresponding to ICxValue interface in the assembly converted by tlbimp.exe
ConfirmVal e;
obj.SetValue(a, ref b, ref c, d, out e); //Throws COMException with
"Unspecified error" here
....

The signature of SetValue in C# in the assembly is void SetValue(int,ref
int,ref string,object,out ConfirmVal).

Can anybody give a clue?

Thanks in advance.

Simon
Jul 19 '05 #1
1 1699
Hi!

Typically, when you TLBIMP a COM class, the class is actually suffixed with
the "Class" string in its .NET version, while the original class name is
actually made to be an interface. So try this:

CxValueObject d = new CxValueObjectClass();

Regards,
Gaurav Khanna

--
----------------------------------------------------------------------------
----------
Microsoft MVP - .NET, MCSE Windows 2000/NT4, MCP+I
WinToolZone - Spelunking Microsoft Technologies
http://www.wintoolzone.com/
OpSupport - Spelunking Rotor
http://opsupport.sscli.net/
----------------------------------------------------------------------------
----------

"Simon LU" <lu****@hotmail.com> wrote in message
news:uq**************@TK2MSFTNGP12.phx.gbl...
I have a COM component in ATL, one of its method's IDL define is as the
following:
HRESULT SetValue(long a, [in] long* b,[in]string* c, [in]VARIANT* d,
[out,retval] ConfirmVal e);
here ConfirmVal is a Enum define by IDL.

The VC++ client has no problem to call it by using smart pointer as the
followings:
long a=0;
long b=-1;
CComBSTR c=L"NAME";
d = ICxValuePtr(__uuidof(ICxValue)); //d is another smartpointer, it is a IDispatch interface in IDL
ConfirmVal e;
ptr->SetValue(a,&b,&c,d,&e)
...

When my C# client calls it as the followings, it throws COMException with
"Unspecified error":
int a=0;
int b=-1;
string c="NAME";
CxValueObject d = new CxValueObject(); //CxValueObject is the class
corresponding to ICxValue interface in the assembly converted by tlbimp.exe ConfirmVal e;
obj.SetValue(a, ref b, ref c, d, out e); //Throws COMException with
"Unspecified error" here
...

The signature of SetValue in C# in the assembly is void SetValue(int,ref
int,ref string,object,out ConfirmVal).

Can anybody give a clue?

Thanks in advance.

Simon

Jul 19 '05 #2

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

Similar topics

3
by: Nick L. | last post by:
All, This is a general question regarding how, and if, compiler optimization techniques affect the general concept of being able to update a component of an application without requiring a...
0
by: Ted | last post by:
I'm using a 3rd party ActiveX control which has it's own constructor and two very methods (which ultimately sends out messages on the server's USB or serial port). I am trying to run this ActiveX...
1
by: Ambush | last post by:
I am currently working on one of those projects that we all dread. The type that keeps growing out of scope faster than you can finish the component to deliver what they've already asked for. ...
0
by: acharyaks | last post by:
Hi life saver, I am using excel component for the development. The purpose is to connect to excel through the odbc connection string. Then through the connection extract data into a dataset and...
0
by: Steven Kilby | last post by:
I have a component (inproc dll) written in VB6. I have a client written in C#. If I compile the component to native code everything works fine. I add the necessary type library for my component...
5
by: Stuart Dee | last post by:
Hi, I have created a com+ component with vb dot net using jit activation and transactions If i call it like this x=createobject("mycomp") x.dispose
7
by: jwang | last post by:
I am trying to instantiate a COM component in C# via late binding. The component appears to be launched, then it automatically gets unloaded. That is, the instance is unloaded after the...
7
by: Joe | last post by:
Is it possible to have a component which is global to the entire application? I need to have a single component act sort of like a server which components in any of the forms can access. For...
1
by: wanaruk | last post by:
Hi all. I am working on a legacy application written in Classic ASP with VB6 COM+ components running on Windows 2003 Adv Server (32bit). There is one page in the app that uses Secure FTP to send...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.