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

OneSignal fails with an exceptionusing MAUI and a device of Windows desktop: #97

Closed
1 task done
pmoran1947 opened this issue Mar 12, 2024 · 2 comments
Closed
1 task done

Comments

@pmoran1947
Copy link

pmoran1947 commented Mar 12, 2024

What happened?

In the application App.xaml.cs, I get an exception with the statement
OneSignal.Debug.LogLevel = LogLevel.VERBOSE;

I am using Visual Studio 17.9 and OneSignalSDK.DotN1et 5.1.1

Steps to reproduce?

1. Create the default MAUI app using the VS templates
2. Add OneSignalSDK.DotNet package
3. Add the using statements
using OneSignalSDK.DotNet;
using OneSignalSDK.DotNet.Core;
using OneSignalSDK.DotNet.Core.Debug;
4. After calling InitializeComponent(), add the statement
           OneSignal.Debug.LogLevel = LogLevel.VERBOSE;
5. run the debug version with a target of Windows Machine

What did you expect to happen?

I expect the app to run but it fails with an exception
The type initializer for 'OneSignalSDK.DotNet.OneSignal' threw an exception.

Relevant log output

'MauiApp1.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.2\netstandard.dll'. 
'MauiApp1.exe' (CoreCLR: clrhost): Loaded 'D:\Development\MauiApp1\MauiApp1\bin\Debug\net8.0-windows10.0.19041.0\win10-x64\AppX\OneSignalSDK.DotNet.Core.dll'. 
'MauiApp1.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.2\System.Runtime.Loader.dll'. 
'MauiApp1.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.2\System.ComponentModel.TypeConverter.dll'. 
Exception thrown: 'System.NotImplementedException' in OneSignalSDK.DotNet.dll
Exception thrown: 'System.TypeInitializationException' in OneSignalSDK.DotNet.dll
'MauiApp1.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\PrivateAssemblies\Runtime\Microsoft.VisualStudio.Debugger.Runtime.NetCoreApp.dll'.

Code of Conduct

  • I agree to follow this project's Code of Conduct
@emawby
Copy link
Contributor

emawby commented Mar 19, 2024

@pmoran1947 Thanks for reaching out have you been able to get this to work or are you still running into this issue? How did you add the OneSignalSDK.DotNet package?

@jkasten2
Copy link
Member

jkasten2 commented Mar 21, 2024

@pmoran1947 Thanks for reporting, this is because this SDK doesn't support Windows.

The key part of the error message is:

Exception thrown: 'System.NotImplementedException' in OneSignalSDK.DotNet.dll

Sorry we didn't have this documented well but I would recommend creating a class to route OneSignal calls through, omit calling OneSignal on your Windows builds.

If you are interested in Windows support OneSignal supports it but there isn't an SDK, it requires using Microsoft's APIs and making REST API calls to OneSignal. See OneSignal's Windows App Setup doc for more details.

  • If SDK support is something you need let us know, we will consider it based on interest.

Related issues:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants