Closed Ephron-WL closed 8 months ago
I can't repro the problem.
What platform are you compiling for when you see this exception? When I target AnyCPU, I (rightly) see this as a compile error:
warning PInvoke005: This API is only available when targeting a specific CPU architecture. AnyCPU cannot generate this API.
When I target x64 or arm64, compilation succeeds, as expected.
This is using CsWin32 0.3.49-beta. What version are you using?
Additional info:
The ARM64_NT_CONTEXT
struct distinct from CONTEXT
and is only defined for x64 and x86 architectures.
CONTEXT
itself is defined 3 times in the metadata, because it is architecture specific. The presence of the SupportedArchitecture
attribute on the struct is therefore not misplaced as far as I can tell.
Ok, I see what you mean. There are three CONTEXT classes, each with an individual architecture attribute (before I only noticed the one). I'm not using the CsWin32 in a conventional manner. The Generator needs to resolve the target platform. I was able to modify my code so that it could do that and it works fine now. Thank you for your assistance. It is much appreciated.
Actual behavior
Exception: PlatformIncompatibleException: Windows.Win32.System.Diagnostics.Debug.CONTEXT is not declared for this platform
Expected behavior
Code gen.
Repro steps
NativeMethods.txt
content:IDebugControl4
NativeMethods.json
content (if present):n/a
Context
The Windows.Win32.System.Diagnostics.Debug.CONTEXT appears to have this attribute:
[SupportedArchitecture(Windows.Win32.Foundation.Metadata.Architecture.Arm64)]
This attribute is misplaced. See CONTEXT structure.
Interestingly, there is also a ARM64_NT_CONTEXT that probably should have this attribute and possibly influenced the generation of the errant attribute on CONTEXT.