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

Mixed mode COM issues

Hi,

Sorry for posting this in C# group as well as C++, but i'm desperate for
some guidance....

I want to create a mixed mode C++ dll that calls a COM object and returns a
managed string. I use the following steps but still get errors:
Created a new C++ .Net Class library project
Add the #import directive to my managed objects header file: #import
"C:\Documents and Settings\alowe\My Documents\ePathwayRequestBrokerDev.dll"
rename_namespace("ePathwayCOM")
Add a new method:

System::String* Execute(String* serviceName, String* xml) {
BSTR service = (BSTR)(void*)Marshal::StringToBSTR(serviceName);
BSTR message = (BSTR)(void*)Marshal::StringToBSTR(xml);
ePathwayCOM::_esyv0004Ptr broker;
broker->exec(service, message);
Marshal::FreeBSTR((void*)service);
Marshal::FreeBSTR((void*)message);
return "test";
}

Followed the instructions in
http://support.microsoft.com/default...b;en-us;814472 to make the
necessary project property changes
Added the ManagedWrapper class as stated in the instructions in the link
above
I then created a C# project to call the manged method however the call to
System::String* Execute(String* serviceName, String* xml); fails with a huge
COM error

Can anyone point out any mistakes i'm making please. I'm extremely desperate
to get his working
Thanks a billion in advance

andrew

Nov 16 '05 #1
3 2379
Andrew,

You say it fails with a huge COM error. What is the error?

Also, when you debug, can you verify that your parameters are being
passed correctly?

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"andrew lowe" <andrew [dot] lowe [at] geac [.] com> wrote in message
news:es***************@TK2MSFTNGP10.phx.gbl...
Hi,

Sorry for posting this in C# group as well as C++, but i'm desperate for
some guidance....

I want to create a mixed mode C++ dll that calls a COM object and returns
a managed string. I use the following steps but still get errors:
Created a new C++ .Net Class library project
Add the #import directive to my managed objects header file: #import
"C:\Documents and Settings\alowe\My
Documents\ePathwayRequestBrokerDev.dll" rename_namespace("ePathwayCOM")
Add a new method:

System::String* Execute(String* serviceName, String* xml) {
BSTR service = (BSTR)(void*)Marshal::StringToBSTR(serviceName);
BSTR message = (BSTR)(void*)Marshal::StringToBSTR(xml);
ePathwayCOM::_esyv0004Ptr broker;
broker->exec(service, message);
Marshal::FreeBSTR((void*)service);
Marshal::FreeBSTR((void*)message);
return "test";
}

Followed the instructions in
http://support.microsoft.com/default...b;en-us;814472 to make the
necessary project property changes
Added the ManagedWrapper class as stated in the instructions in the link
above
I then created a C# project to call the manged method however the call to
System::String* Execute(String* serviceName, String* xml); fails with a
huge COM error

Can anyone point out any mistakes i'm making please. I'm extremely
desperate to get his working
Thanks a billion in advance

andrew

Nov 16 '05 #2

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:eF**************@TK2MSFTNGP15.phx.gbl...
Andrew,

You say it fails with a huge COM error. What is the error?

Also, when you debug, can you verify that your parameters are being
passed correctly?


Nicholas,

I've moved on from that error now and have a StackOverFlowException being
raised when i call the exec method:
BSTR service;
BSTR xml;
........
broker->exec(&service, &xml);

The compiler generated source file for the smart pointer class has the
definition
inline long _esyv0111::exec ( BSTR * servicename, BSTR * xml_message ) {
long _result = 0;
_com_dispatch_method(this, 0x3ea, DISPATCH_METHOD, VT_I4, (void*)&_result,
L"\x4008\x4008", servicename, xml_message);
return _result;
}

The weird thing is it only happens when the xml parameter starts returning a
string that is greater than roughly 600kb. The Com object is written in
Uniface so i can't change or look at the memory allocation inside of this
object. My c++ is rusty so i'm wondering if i'm calling the method in the
correct manner or if the 4mb of stack space is being abused ??. I can
guarentee that no recursion is taking place

thanks,
andrew
Nov 16 '05 #3
The stack space is by default 1MB. So it looks like "exec" is consuming all
the stack space when executing. Did you try to attach a debugger?

Willy.

"andrew lowe" <andrew [dot] lowe [at] geac [.] com> wrote in message
news:ux**************@TK2MSFTNGP11.phx.gbl...

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:eF**************@TK2MSFTNGP15.phx.gbl...
Andrew,

You say it fails with a huge COM error. What is the error?

Also, when you debug, can you verify that your parameters are being
passed correctly?


Nicholas,

I've moved on from that error now and have a StackOverFlowException being
raised when i call the exec method:
BSTR service;
BSTR xml;
.......
broker->exec(&service, &xml);

The compiler generated source file for the smart pointer class has the
definition
inline long _esyv0111::exec ( BSTR * servicename, BSTR * xml_message ) {
long _result = 0;
_com_dispatch_method(this, 0x3ea, DISPATCH_METHOD, VT_I4, (void*)&_result,
L"\x4008\x4008", servicename, xml_message);
return _result;
}

The weird thing is it only happens when the xml parameter starts returning
a string that is greater than roughly 600kb. The Com object is written in
Uniface so i can't change or look at the memory allocation inside of this
object. My c++ is rusty so i'm wondering if i'm calling the method in the
correct manner or if the 4mb of stack space is being abused ??. I can
guarentee that no recursion is taking place

thanks,
andrew

Nov 16 '05 #4

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

Similar topics

9
by: Edward Diener | last post by:
I received no answers about this the first time I posted, so I will try again. My inability to decipher an MSDN topic may find others who have the same inability and someone who can decipher and...
8
by: Bern McCarty | last post by:
Is it at all possible to leverage mixed-mode assemblies from AppDomains other than the default AppDomain? Is there any means at all of doing this? Mixed-mode is incredibly convenient, but if I...
8
by: Nadav | last post by:
Hi, I am writing a performence critical application, this require me to stick to unmanaged C++ as performance is much better using unmanaged C++ ( about 33% better ), Still, I am trying to avoid...
7
by: Staale L. Hansen | last post by:
We have an application which uses some mixed-mode code to expose a .NET 1.1 managed API. Only the necessary files are compiled with /clr. We want to be able to load the application without .NET...
1
by: Tal | last post by:
Do you know if I can use a mixed mode C++ dll from an unmanaged C++ dll? I need it because I want to use C# class located in dll from unmanaged C++ code located in dll. I thought maybe I can...
4
by: bonk | last post by:
This article http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmex/html/vcconconvertingmanagedextensionsforcprojectsfrompureintermediatelanguagetomixedmode.asp seems to be...
2
by: Ubergeek | last post by:
I recently came accross an article that stated that there were unresolved issued with calling native (i.e. "unmanaged" C++) from managed C++. Does anyone know what the precise details of this...
8
by: Edward Diener | last post by:
By reuse, I mean a function in an assembly which is called in another assembly. By a mixed-mode function I mean a function whose signature has one or more CLR types and one or more non-CLR...
0
by: emu | last post by:
Hi All, I have an unmanaged C++ application that references a mixed mode image DLL (mixed managed and unmanaged). Under .NET 1.1 we could trust the dll (the mixed mode dll) by running the...
1
by: Bern McCarty | last post by:
I know how with VC8 you embed your linker generated manifest into an exe with a resource ID of #1 and into a dll with resource ID #2. But what do you do with the linker generated manifest for a...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.