Redian新闻
>
Need Help: a very wierd Managed C++ interop problem
avatar
Need Help: a very wierd Managed C++ interop problem# DotNet - 窗口里的风景
O*l
1
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 ov
avatar
k*i
2
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.

component
.
the

【在 O*****l 的大作中提到】
: 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 ov

avatar
O*l
3
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
. :)
avatar
k*i
4
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.

Thanks

【在 O*****l 的大作中提到】
: 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
: . :)

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。