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

Managed C++ & COM

I wrote a managed C++ class that makes COM calls to INetConnectionManager to
enable/disable network connections. Unfortunately, the following call seems
to fail with a result of -2147417843 when calling this managed code from any
..Net application. The line that fails is:

HRESULT hres = CoCreateInstance(CLSID_ConnectionManager, 0, CLSCTX_ALL,
__uuidof(INetConnectionManager), (void**)&pMan);

However, if I take the same code and put it in a non-managed application, it
works fine.

Are there special considerations that need to be taken when calling COM code
from within managed code within a .Net application?

Joe

Nov 17 '05 #1
2 2683
Not sure if this helps, but the error code maps to the following: "An
outgoing call cannot be made since the application is dispatching an
input-synchronous call."
Nov 17 '05 #2
It is illegal to directly call to COM objects from managed code. You have to
use COM callable wrapper. More info is here
http://msdn.microsoft.com/library/de...blewrapper.asp
and more theory on Interop
http://msdn.microsoft.com/library/en...anagedcode.asp

Thanks,

--
Nikola Dudar
Visual C++; // Program Manager
This posting is provided "AS IS" with no warranties, and confers no rights.

"Joe Kinsella" <jo*@nospamplease.com> wrote in message
news:Ot**************@tk2msftngp13.phx.gbl...
I wrote a managed C++ class that makes COM calls to INetConnectionManager
to
enable/disable network connections. Unfortunately, the following call
seems
to fail with a result of -2147417843 when calling this managed code from
any
.Net application. The line that fails is:

HRESULT hres = CoCreateInstance(CLSID_ConnectionManager, 0, CLSCTX_ALL,
__uuidof(INetConnectionManager), (void**)&pMan);

However, if I take the same code and put it in a non-managed application,
it
works fine.

Are there special considerations that need to be taken when calling COM
code
from within managed code within a .Net application?

Joe

Nov 17 '05 #3

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

Similar topics

2
by: Dave | last post by:
Hi, I'm writing a research simulation program and would like to write it in c++. It should be as fast as possible and am not sure if it makes a difference to use managed or unmanaged code. I will...
0
by: Johannes Unfried | last post by:
Problem Best practice needed to marshal STL data from managed code to unmanaged code & vice vers Details managed code is written in managed C++ & accesses the unmanaged code (i.e. lives in a...
7
by: wmkew | last post by:
Hello everyone I'm encountering a R6002 Runtime error and several bugs when trying to generate a simple Managed C++ application with .NET 2003. The main problem seems to arise from linking with...
4
by: Werner | last post by:
Hello I have a VC7 App consisting of "old" MFC-Source and new Manged Source that uses an OC in one of its MFC-based dialogs When started, AfxOleInit (called in InitInstance) fails with a message...
0
by: Lars Grøtteland | last post by:
Hello! We have a pretty large application written in VC6.0 (MFC). To be familiar with .NET we began to use .NET 2003 version, and still write our code in C++. I tried to select the "Use...
6
by: Chris Wood | last post by:
I have a complex codebase developed in Managed C++ that I am not particularly looking forward to porting to C++/CLI :) I'd like to know what the most compelling arguments for doing so are so I can...
11
by: Lloyd Dupont | last post by:
(not I use 2.0, so new return a "normal" pointer and gcnew return a managed one, my question below regarding new concern plain standart C++ allocator) - if I use the default new operator, are all...
2
by: Ian | last post by:
1. I want to be use mix unmanaged code with managed code. In particular, the unmanaged code uses MFC CFile to perform file I/O. Can CFile be used in unmanaged code that is mixes with managed...
25
by: Koliber (js) | last post by:
sorry for my not perfect english i am really f&*ckin angry in this common pattern about dispose: ////////////////////////////////////////////////////////// Public class...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
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
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.