Skip to content

#elif WINDOWS doesn't work #6815

@nk54

Description

@nk54

Description

I want to create a service and use dependency injection.

It works on each platform except windows.
First, #elif __WINDOWS__ wasn't taken into account by Visual Studio (see screenshot below)
image

Next, #elif WINDOWS was recognized by Visual Studio but not by the compiler as it tells me it can't find the implementation of my service.

It should work and the documentation MUST (just my opinion, you're the boss haha) be updated to tell to developpers what's the difference between #if __ANDROID__ and #if ANDROID
On the Microsoft documentation I saw both, it's quite confusing. Even more when #if __WINDOWS__ doesn't work while #if WINDOWS does.

Edit: answer given here don't use the double underscore.

Steps to Reproduce

  • create an interface inside the MAUI project
  • create an implementation of that interface inside each platforms folder
  • try to register the service inside MauiProgram.cs

Version with bug

Release Candidate 2 (current)

Last version that worked well

Unknown/Other

Affected platforms

Windows (I'm using Visual Studio 17.2.0 Preview 6.0)

Affected platform versions

net6.0-windows10.0.19041

Did you find any workaround?

Yes !

I handle each platform and handle WINDOWS in the #else

But it's a dirty hack because if the problem occurs on Tizen too, it cannot work

Relevant log output

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions