473,378 Members | 1,375 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,378 software developers and data experts.

how to return failure HRESULTs from .NET to COM

Hi all
I posted a related question a couple days back. I did get
a few helpful replies. However, I've not yet figured out
the solution.

I've read that passing HRESULTs back from .NET to COM is
not a good practice. Exceptions should be thrown and sent
back to COM.

I'm rewriting a C++ program in C#. The C++ program used to
return an LPVARIANT type under success conditions and
HRESULTs under failure conditons. The C# dll is supposed
to return a System.object. When an error occurs, I throw
an exception back to the caller. The caller (a VB script
COM component) checks for FAILED(hr).

issues:
1.When an exception is thrown from .NET to the client,
FAILED(hr) is false. (I expected it to be true).

2.I tried to convert the exception into an HRESULT and
return it back to the caller (using
Marshal.GetHRForException() method.) In this case, I get a
VBScript runtime error because it is expecting a
System.object type to be returned from C#, instead an
Int32 HRESULT is returned.

Any help is appreciated.
thanks.

Nov 15 '05 #1
0 1013

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

Similar topics

4
by: Bruce A. Julseth | last post by:
I know the following $sql will fail since there is no Customer='Smith'. I want to determine how to test a failure of mysql_query. I thought mysql_query returned false if a query failed. The test...
4
by: Paul | last post by:
Hi, In SQL Books Online in the section on @@Error it gives the following example: -- Execute the INSERT statement. INSERT INTO authors (au_id, au_lname, au_fname, phone, address, city,...
27
by: Maximus | last post by:
Hi, I was just wondering, is it good to use return without arguments in a void function as following: void SetMapLayer() { if( !Map ) return; layer = LAYER_MAP; }
2
by: Alex Vinokur | last post by:
------ foo.cpp ------ #include <iostream> using namespace std; int main() { #define FACTOR 10 for (unsigned long array_size = 1; ; array_size *= FACTOR) { int* p = new int;
0
by: Mark | last post by:
xp_startmail is documented as returning two code: 0 success, 1 failure. It would be nice to check the return code. When mail has already been started it returns a 1. This case appears...
16
by: Fao, Sean | last post by:
As far as I can tell, the standard has defined three portable return codes from function main() (0, EXIT_SUCCESS, EXIT_FAILURE). Personally, on all platforms I have worked with, EXIT_SUCCESS is,...
24
by: Earl | last post by:
I have all of my data operations in a separate library, so I'm looking for what might be termed "best practices" on a return type from those classes. For example, let's say I send an update from...
11
by: quarkLore | last post by:
I have seen redundant return statements at the end of function. e.g. void init_function(void) { a_init(); b_init(); c_init(); return; } I checked the generated code in GCC Compiler 3.2.2 on...
11
by: polas | last post by:
Good afternoon all, I appreciate that the standard requires that main should return an integer. What I was wondering though is there any accepted standardisation on exactly what value to return...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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...

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.