Simple COM question
-
Friday, February 24, 2012 2:24 PM
We are converting VC++ COM component to VB.NET, gradualy. Our new VB.NET modules are called by the core VC++ program, so they need to be COM enabled until we convert the core module. We ran accros the following:
An error class is defined and returned to the COM core when exception occurs. The error class is in VC++ DQSError.DLL:
coclass DQSError { [default] interface IDQSError; ... };In the core module IDL, the IDQSError interface is "redefined" as it is the return value of many methods.
interface IDQSEror : IDispatch { ....Our new VB.NET component, references the core COM module and implements one of its COM interface:
<ComClass(...)> _ Public Class MyClass Implements MyCore.IClientApp Public Function CoreFonc(...) as MyCore.IDQSError Implements MyCore.CoreFonc ... End FunctionHowever the real error class exists in the error module, so with option strict on, we canno return a DQSError class as a result of the call to CoreFonc, unless we DirectCast it
This double defininition ie IDQSError bugs us. Is anything wrong with what we do here ?Dim error1 as ErrorModule.DQSError = new ErrorModule.DQSError("error message") return DirectCast( error, MCore.IDQSError)
All Replies
-
Monday, February 27, 2012 7:51 AMModerator
Hi Keboo,
Welcome to the MSDN Forum.
Based on my understanding, there is nothing wrong.
At first, please take a look at this article: http://msdn.microsoft.com/en-us/library/zcd4xwzs(v=vs.100).aspx
Restricts implicit data type conversions to only widening conversions, disallows late binding, and disallows implicit typing that results in an Objecttype.
And this one: http://support.microsoft.com/kb/311329
Option Strict restricts implicit data type conversions to only widening conversions. Widening conversions explicitly do not permit any data type conversions in which data loss may occur and any conversion between numeric types and strings. For more information about widening conversions, see the Widening Conversions section.
In your .net code, you have declared the return type is MyCore.IDQSError, based on the above articles, you can only return this type.
I hope this will be helpful.
Best regards,
Mike Feng
MSDN Community Support | Feedback to us
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Marked As Answer by RebootUniverse Monday, March 05, 2012 5:06 PM
-
Monday, March 05, 2012 3:49 PMModerator
Hi Keboo,
I didn't hear from you a couple of days.
How about your issue now?
Do you have any update?
Best regards,
Mike Feng
MSDN Community Support | Feedback to us
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

