How to write C # code safe both with x86 and x64 when accessing COM? Typical traps?

We use an open source library written in C # that includes the Windows BITS COM component. However, the code can be safely run in x86 mode. I would like to contribute to the library by making it safe for both x86 and x64, however I do not have deep knowledge in this area.

Could you list here good / bad practices, typical problems, and maybe principles, etc., what should you pay attention to?

For example, I saw in the code a IntPtrvalue System.Int32that is not well ported to x64. How would you view these and similar problems in an agnostic form of the platform?

+3
source share
2 answers

I think you say SharpBits.NET , a wrapper for the BITS component. Yes, there are several places where the author was looking for a break. Otherwise, there is no reason why it cannot work, BITS is available both in 32-bit and 64-bit COM-server. One example of such a mess is this stream .

Receiving a P / Invoke declaration by incorrect or incorrect manual marshaling is the vast majority of all 64-bit interaction problems. I left a lot of advice on 64-bit coding problems in this thread .

+2
source

Hm, you do not;)

Seriously.

, 64- 32- COM- , stron ( COM, COM IDispatch) wrapepr.

x86/x64 - - , . , yuo 32- DLL 64- - , .

MS , . - .

+1

Source: https://habr.com/ru/post/1736461/


All Articles