Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.NET client fails to load on Windows WPF apps, assumes it is on MAUI #60

Open
rbakhshi opened this issue Aug 29, 2024 · 6 comments
Open

Comments

@rbakhshi
Copy link

Describe the bug
Client sdk 5.0.0 fails to load in a WPF app in .NET8 net8.0-windows.

To reproduce

  • Create a simple WPF all using .NET8 (TargetFramework net8.0-windows).
  • Add launchdarkly client sdk 5.0.0
  • Init the sdk: LdClient.Init(context)

Expected behavior
It should not fail

Logs

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Maui.Essentials, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Maui.Essentials, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'Microsoft.Maui.Essentials, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
   at LaunchDarkly.Sdk.Client.PlatformSpecific.PlatformConnectivity.get_LdNetworkAccess()
   at LaunchDarkly.Sdk.Client.Internal.DataSources.DefaultConnectivityStateManager.UpdateConnectedStatus()
   at LaunchDarkly.Sdk.Client.Internal.DataSources.DefaultConnectivityStateManager..ctor()
   at LaunchDarkly.Sdk.Client.Internal.Factory.CreateConnectivityStateManager(Configuration configuration)
   at LaunchDarkly.Sdk.Client.LdClient..ctor(Configuration configuration, Context initialContext, TimeSpan startWaitTime)
   at LaunchDarkly.Sdk.Client.LdClient.CreateInstance(Configuration configuration, Context initialContext, TimeSpan maxWaitTime)
   at LaunchDarkly.Sdk.Client.LdClient.Init(Configuration config, Context initialContext, TimeSpan maxWaitTime)

SDK version
LD 5.0.0

Language version, developer tools

> dotnet --version
8.0.401

OS/platform
Windows 10

Additional context
Add any other context about the problem here.

@rbakhshi rbakhshi changed the title .NET client fails to load on Windows WPF apps, assuming it is on MAUI .NET client fails to load on Windows WPF apps, assumes it is on MAUI Aug 29, 2024
@tanderson-ld
Copy link
Contributor

tanderson-ld commented Aug 29, 2024

hi @rbakhshi, thank you for reporting this. We will investigate and get back to you in the next few days. Filed internally as 254757.

@rbakhshi
Copy link
Author

For anyone interested, I found this as a workaround while a fix is being made for this.

The issue is that from all the target frameworks we only need netstandard2.0 version in our application and we don't want to use net7.0-windows because it has a hard tie to MAUI.

The way to do it is by changing the PackageReference as follows and explicitly reference the dlls:

    <PackageReference Include="LaunchDarkly.ClientSdk" Version="5.0.0" ExcludeAssets="Compile" GeneratePathProperty="true"/>
    <Reference Include="LaunchDarkly.ClientSdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=90b24964a3dfb906">
      <HintPath>$(PkgLaunchDarkly_ClientSdk)\lib\netstandard2.0\LaunchDarkly.ClientSdk.dll</HintPath>
    </Reference>
    <PackageReference Include="LaunchDarkly.CommonSdk" Version="7.0.0" ExcludeAssets="Compile" GeneratePathProperty="true"/>
    <Reference Include="LaunchDarkly.CommonSdk, Version=7.0.0.0, Culture=neutral, PublicKeyToken=45ef1738a929a7df">
      <HintPath>$(PkgLaunchDarkly_CommonSdk)\lib\netstandard2.0\LaunchDarkly.CommonSdk.dll</HintPath>
    </Reference>

Note that now you need to explicitly reference CommonSdk.

@sohail-p
Copy link

@tanderson-ld This is still reproducing for me, any timelines for a fix?

@tanderson-ld
Copy link
Contributor

Hi @sohail-p . We don't have a timeline for fixing it at the moment. Does the workaround shared work for your situation?

@sohail-p
Copy link

@tanderson-ld we do not want to add Maui Package to our solution. Is there any other way?

@tanderson-ld
Copy link
Contributor

The netstandard2.0 DLL doesn't include any MAUI components. Do you see the issue with the hint path workaround rbakhshi posted?

@cwaldren-ld cwaldren-ld transferred this issue from launchdarkly/dotnet-client-sdk Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants