473,406 Members | 2,371 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,406 software developers and data experts.

using COM from VC (either managed or unmanaged)

Hello
I have a problem with creating a COM object from C++.
The COM object is called, say, My3rdPartyDLL.MyCOMObject.
When I do it from unmanaged C++, with smart pointers, the DLL gets #imported
fine and it compiles OK. But when it gets to it, it has an unhandled
(unhandleable?) exception which pops up with the message 'User breakpoint
called', even with try..catch round it.
This is when using the syntax
My3rdPartyDLL::_MyCOMObjectPtr myobj(__uuidof(My3rdPartyDLL::MyCOMObject));
or
My3rdPartyDLL::_MyCOMObjectPtr myobj;
myobj.CreateInstance(__uuidof(My3rdPartyDLL::MyCOM Object));
When I try and do it from managed code, using
My3rdPartyDLL::MyCOMObjectClass* myobj = __gc new
My3rdPartyDLL::MyCOMObjectClass();

it does the same thing, and still a try..catch fails to handle the exception.

This COM object is protected with a dongle, but the dongle is definitely
plugged in.
The weird thing is that this method works fine on other COM objects, like a
sample one I knocked up to emulate it in VB6.
The protected COM object that I want to use also works fine from C# or VB6.
Why won't it work from ANY variety of C++ then?
Any help much appreciated
Cheers
Nov 17 '05 #1
2 1181
I've remembered to call CoInitialize.
"Bonj" wrote:
Hello
I have a problem with creating a COM object from C++.
The COM object is called, say, My3rdPartyDLL.MyCOMObject.
When I do it from unmanaged C++, with smart pointers, the DLL gets #imported
fine and it compiles OK. But when it gets to it, it has an unhandled
(unhandleable?) exception which pops up with the message 'User breakpoint
called', even with try..catch round it.
This is when using the syntax
My3rdPartyDLL::_MyCOMObjectPtr myobj(__uuidof(My3rdPartyDLL::MyCOMObject));
or
My3rdPartyDLL::_MyCOMObjectPtr myobj;
myobj.CreateInstance(__uuidof(My3rdPartyDLL::MyCOM Object));
When I try and do it from managed code, using
My3rdPartyDLL::MyCOMObjectClass* myobj = __gc new
My3rdPartyDLL::MyCOMObjectClass();

it does the same thing, and still a try..catch fails to handle the exception.

This COM object is protected with a dongle, but the dongle is definitely
plugged in.
The weird thing is that this method works fine on other COM objects, like a
sample one I knocked up to emulate it in VB6.
The protected COM object that I want to use also works fine from C# or VB6.
Why won't it work from ANY variety of C++ then?
Any help much appreciated
Cheers

Nov 17 '05 #2
What's failing, the CreateInstance call or a function call?

"Bonj" wrote:
Hello
I have a problem with creating a COM object from C++.
The COM object is called, say, My3rdPartyDLL.MyCOMObject.
When I do it from unmanaged C++, with smart pointers, the DLL gets #imported
fine and it compiles OK. But when it gets to it, it has an unhandled
(unhandleable?) exception which pops up with the message 'User breakpoint
called', even with try..catch round it.
This is when using the syntax
My3rdPartyDLL::_MyCOMObjectPtr myobj(__uuidof(My3rdPartyDLL::MyCOMObject));
or
My3rdPartyDLL::_MyCOMObjectPtr myobj;
myobj.CreateInstance(__uuidof(My3rdPartyDLL::MyCOM Object));
When I try and do it from managed code, using
My3rdPartyDLL::MyCOMObjectClass* myobj = __gc new
My3rdPartyDLL::MyCOMObjectClass();

it does the same thing, and still a try..catch fails to handle the exception.

This COM object is protected with a dongle, but the dongle is definitely
plugged in.
The weird thing is that this method works fine on other COM objects, like a
sample one I knocked up to emulate it in VB6.
The protected COM object that I want to use also works fine from C# or VB6.
Why won't it work from ANY variety of C++ then?
Any help much appreciated
Cheers

Nov 17 '05 #3

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

Similar topics

12
by: Wayne | last post by:
We have some old win32 apps and I still need to support these applications. I'd like to do new and future enhancements in C#, if at all possible. Is there a way to use a .net assembly in a normal...
47
by: Bonj | last post by:
I downloaded the gzlib library from zlib in order to do compression. (http://www.gzip.org/zlib) The prototype of the compression function seems to be int compress (Bytef *dest, uLongf *destLen,...
1
by: Eric Twietmeyer | last post by:
Hello, I'm starting to investigate cs, managed c++ and interoperating with a very large unmanaged code base. We are going to use Windows Forms (written in cs) to replace our old fashioned GUI. ...
8
by: Mas L via DotNetMonster.com | last post by:
Hi, I have a c++ source code which I can compile to be a DLL (in VS.NET 2003). And I need to use it in a C# program. After I compiled/build the C++ code to a DLL, I add it as a Reference in my...
3
by: mirek | last post by:
Hi, I've got problem building managed class library to wrap unmanaged code. I created managed class library using standard patten: #include "../Unmanaged/Class1.h" //Class1 unmanaged ...
7
by: Kristof Thys via .NET 247 | last post by:
Post a new message to microsoft.public.dotnet.languages.vc http://www.dotnet247.com/247reference/default.aspx Hello, I've been struggling for weeks with this problem, I hope I find some...
5
by: Andrew | last post by:
I want to use a managed c++ class from an unmanaged class. Here is my code: // *** Unmanaged Code // .h file class UnmanagedClass { public: // Other stuff here
1
by: RaKKeR | last post by:
Hi, I'm trying to wrap my unmanaged c++ code into a managed c++ wrapper. The problem is VC .NET doesn't seem to find the namespaces defined in my unmanaged code. Let's say I have a file...
12
by: DaTurk | last post by:
Hi, I have a rather interesting problem. I have a unmanged c++ class which needs to communicate information to managed c++ via callbacks, with a layer of c# on top of the managed c++ ultimatley...
5
by: Richy | last post by:
Hi, This is a Direct3D-related question but I am posting it in here as it is more VB-specific. I have an effect file that I am trying to set the values for. For example: ...
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: 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...
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
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
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
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
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,...

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.