当前在线人数16186
[合集] Need Help: a very wierd Managed - 未名空间精华区
首页 - 版面精华区 - 电脑网络精华区 - 窗口里的风景版精华区 - 精华区文章阅读 首页
未名交友
[更多]
[更多]
[合集] Need Help: a very wierd Managed

发信人: les (Walk the walk, talk the talk), 信区: DotNet
标  题: [合集] Need Help: a very wierd Managed C++ interop problem
发信站: BBS 未名空间站 (Sat May 26 23:07:53 2007), 站内

☆─────────────────────────────────────☆
  OpenXml (Make One SomeOne Happy) 于 (Fri Jan 12 15:03:06 2007) 提到:

DOTNET gurus, I really need your help on this wierd behavior.

We have a system written in native c++; The system calls to a COM component
to perform some calculations.  In one of the methods, we need to cast a
struct as an array of bytes (BYTE *) and also passes the size of the array.
It all works fine until we link the system to a static library which is
written in Managed C++.  The input parameters to the COM method got messed
up.  It appears, the call tries to copy the input parameter data over (
instead of using the passed in pointers).  However, when copying the input
data, it thought the data is of only one byte instead of an array, so it
copies one byte over and messes up the call.  If I remove the linkage to the
managed C++ library, the COM method call would use the original pointers. 
To note, there are no any relation or dependencies between the COM component
and the managed C++ library. 

Sorry that I couldn't input Chinese characters here.  If I didn't state the
problem clear enought, please let me know.

I am really scratching my head on this wierd problem; google results didn't
give me any hints either.  Please help if you have seen anything similar or
even wild guess would help too.  Thanks.


☆─────────────────────────────────────☆
  kongzi (鸡龟骨滚羹) 于 (Fri Jan 12 20:10:45 2007) 提到:

Can you make the managed c++ library a dynamic one so you don't need to link
it into the native c++ system?
My guess is that when you link the managed c++ lib into the native one, the
whole lib will be executed in CLR.
【 在 OpenXml (Make One SomeOne Happy) 的大作中提到: 】
: DOTNET gurus, I really need your help on this wierd behavior.
: We have a system written in native c++; The system calls to a COM
component
: to perform some calculations.  In one of the methods, we need to cast a
: struct as an array of bytes (BYTE *) and also passes the size of the array
.
:  It all works fine until we link the system to a static library which is
: written in Managed C++.  The input parameters to the COM method got messed
: up.  It appears, the call tries to copy the input parameter data over (
: instead of using the passed in pointers).  However, when copying the input
: data, it thought the data is of only one byte instead of an array, so it
: copies one byte over and messes up the call.  If I remove the linkage to
the
: ...................





☆─────────────────────────────────────☆
  OpenXml (Make One SomeOne Happy) 于 (Sat Jan 13 03:17:07 2007) 提到:

Kongzi, thank you so much for your reply.  You were right, it works if I
build the library into dll.  One thing I don't understand is, even if the
program runs under CLR as if I build the system into a mixed managed and
unmanaged code under C++/CLR, shouldn't the CLR know where are the native
code and where are the native code call into native code. 

Anyway, it's very relieved to know a way to work around this problem. Thanks
.  :)


☆─────────────────────────────────────☆
  kongzi (鸡龟骨滚羹) 于 (Sat Jan 13 10:14:41 2007) 提到:

When you link managed code to unmanaged code, the linker might create a
wrapper class of the unmanaged code so the whole thing would be running in
CLR. I am not an expert on this so it's just my guess. Glad that it works
out for you.
【 在 OpenXml (Make One SomeOne Happy) 的大作中提到: 】
: Kongzi, thank you so much for your reply.  You were right, it works if I
: build the library into dll.  One thing I don't understand is, even if the
: program runs under CLR as if I build the system into a mixed managed and
: unmanaged code under C++/CLR, shouldn't the CLR know where are the native
: code and where are the native code call into native code. 
: Anyway, it's very relieved to know a way to work around this problem.
Thanks
: .  :)





[返回]
赞助链接
未名交友
将您的链接放在这儿
 

Site Map - Contact Us - Terms and Conditions - Privacy Policy

版权所有,未名空间(mitbbs.com),since 1996