473,397 Members | 1,950 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,397 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 1701
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
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...
0
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...

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.