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

Can't resolve the reference 'System.IntPtr ObjCRuntime.DisposableObject::get_Handle()' on 4.0.0 beta 3 #275

Closed
Dipannita20 opened this issue Feb 16, 2022 · 15 comments

Comments

@Dipannita20
Copy link

Description:

iOS Build failed, got below log
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(254,3): error MT2101: Can't resolve the reference 'System.IntPtr ObjCRuntime.DisposableObject::get_Handle()', referenced from the method 'System.Void Com.OneSignal.iOS.OSEmailSubscriptionObserverWrapper::OnOSEmailSubscriptionChanged(Com.OneSignal.iOS.OSEmailSubscriptionStateChanges)' in 'Xamarin.iOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'

Environment
Visual Studio 2019 version 16.11.9
OneSignal Xamarin SDK 4.0.0 beta 3
Xamarin iOS and Xamarin.Mac SDK - 15.2.0.17
XCode: 13.2.1
Added SDKs using nuget

Steps to Reproduce Issue:

  1. Upgraded OneSignal Xamarin SDK from 3.10.6 to 4.003 beta
  2. Followed migration https://documentation.onesignal.com/docs/step-by-step-xamarin-3x-to-400-upgrade-guide
  3. Build iOS app failed

Anything else:

(crash stacktraces, as well as any other information here)
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(254,3): error MT2101: Can't resolve the reference 'System.IntPtr ObjCRuntime.DisposableObject::get_Handle()', referenced from the method 'System.Void Com.OneSignal.iOS.OSEmailSubscriptionObserverWrapper::OnOSEmailSubscriptionChanged(Com.OneSignal.iOS.OSEmailSubscriptionStateChanges)' in 'Xamarin.iOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'

@tanaynigam
Copy link
Contributor

@Dipannita20 Thanks for reporting. Please ensure that the OneSignal Nuget references are up-to-date with the same version number. Could you provide the details regarding the type of project you are using the OneSignal SDK for?

If possible, could you also share the code where you are setting up the email subscription observer?
You can also try to turn on verbose logging on your build - https://developercommunity.visualstudio.com/t/error-mt2101-cant-resolve-the-reference/336275

Additionally, are you using an M1 (apple silicon) Mac or an intel chip Mac?

@Dipannita20
Copy link
Author

Dipannita20 commented Feb 28, 2022

Double checked OneSignal Nuget references, all are up-to-date with the same version number 4.0.0 beta 3

image

Its Xamarin Forms project
Microsoft Visual Studio Professional 2019 (2)
Version 16.11.9
VisualStudio.16.Release/16.11.9+32106.194
Microsoft .NET Framework
Version 4.8.04084

Installed Version: Professional

ASP.NET and Web Tools 2019 16.11.94.52318
ASP.NET and Web Tools 2019

Azure App Service Tools v3.0.0 16.11.94.52318
Azure App Service Tools v3.0.0

C# Tools 3.11.0-4.21602.3+fc14a1355c0461af5110b74b26f6478f22d26565
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Extensibility Message Bus 1.2.6 (master@34d6af2)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

IntelliCode Extension 1.0
IntelliCode Visual Studio Extension Detailed Info

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Mono Debugging for Visual Studio 16.10.15 (552afdf)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager 5.11.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

ProjectServicesPackage Extension 1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

TypeScript Tools 16.0.30526.2002
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 3.11.0-4.21602.3+fc14a1355c0461af5110b74b26f6478f22d26565
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 16.11.0-beta.21514.6+b6c2c4f53ea3a08fa603ea93d6d2f808a62a21d1
Microsoft Visual F# Tools

Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for Unity 4.11.4.0
Visual Studio Tools for Unity

VisualStudio.DeviceLog 1.0
Information about my package

VisualStudio.Foo 1.0
Information about my package

VisualStudio.Mac 1.0
Mac Extension for Visual Studio

Xamarin 16.11.000.197 (d16-11@6934992)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer 16.11.0.47 (remotes/origin/d16-11@e0d612363)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates 16.10.5 (355b57a)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK 12.0.0.3 (d16-11/f0e3c2d)
Xamarin.Android Reference Assemblies and MSBuild support.
Mono: c633fe9
Java.Interop: xamarin/java.interop/d16-11@476bb5b
ProGuard: Guardsquare/proguard@912d149
SQLite: xamarin/sqlite@85460d3
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-11@87af37b

Xamarin.iOS and Xamarin.Mac SDK 15.2.0.17 (738fde344)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Chip: Apple M1

Have not setup any Email subscription observer. I have initialize code on App.xaml.cs
OneSignal.Default.Initialize(appSettingsService.OneSignalAppId);

Attached full build diagnostic log
onesignal_ios_build_log.txt

@tanaynigam
Copy link
Contributor

@Dipannita20 Thanks for providing the details. Upon reproducing the issue, we were able to conclude that the issue does not exist in Xamarin.iOS versions above 15.4 and would suggest updating to the latest Xamarin version using the Visual Studio installer

Alternatively, if updating the Xamarin version is not preferred, you could also change the linker behavior to Don't Link on your Xamarin-iOS project. You can do this by right-clicking your Xamarin-iOS project > Options > iOS Build > Linker Behavior > Don't Link
Screen Shot 2022-03-04 at 5 34 32 PM

we'll also be updating our docs to make a note of this requirement for the 4.0.0 release

@Dipannita20
Copy link
Author

Dipannita20 commented Mar 7, 2022

@tanaynigam Thanks for the information.

I checked the Xamarin.iOS version which is 15.2.0.17(basically I use windows system which has latest visual studio 2019 16.11.10 and pair mac to build iOS app, Xamarin.iOS version 15.2.0.17 is available on latest visual studio 2019 windows and same get sync with Mac) . I tried alternative by setting linker behaviour to Don't Link. build was successful, notification sent. Received notification, however on tap of notification app crashed. Attached log.

OneSignal_notification_error_7th_march.txt

Attached OneSignal service class file(changed extension from cs=>txt) which get initialized on App.xmal.cs
OneSignalService.txt

So do I have only option to upgrade Xamarin.iOS versions above 15.4?

I have installed latest beta(ignore android part)

image

@jkasten2
Copy link
Member

jkasten2 commented Mar 7, 2022

@Dipannita20 Thanks for trying out the "Don't Link" build setting, good to hear that fixed build issue.

For the crash you are seeing now I check the log and it is the same issue as reported in #274:

Com.OneSignal.NativeConversion.NotificationToXam (Com.OneSignal.iOS.OSNotification notification) [0x00000] in /Users/tanay/Desktop/Xamarin_SDK/OneSignal_Xamarin-4_0_0/OneSignal-Xamarin-SDK/Com.OneSignal.iOS/Utilities/NativeConversion.cs:41 

This was fixed in PR #276 and has been released in 4.0.0-beta4. I see your screenshot does show 4.0.0-beta4 already but since your stacktrace line numbers are still pointing to beta3 it seems the updated did not apply. I recommend doing a clean build to ensure OneSignal has been updated in your app.

@jkasten2
Copy link
Member

jkasten2 commented Mar 8, 2022

Additional details on ObjCRuntime.DisposableObject. It was added sometime after 15.2.0 as it is included in this "Xamarin.iOS SDK API diff: 15.2.0 vs 15.5.0" diff report:

@Dipannita20
Copy link
Author

Dipannita20 commented Mar 8, 2022

@jkasten2

I double checked and clean build, did a clean deployment. I am on latest beta4
without providing Additional data, on receiving/notification tap app is crashing. This is also wired sometimes app is crashing while receiving the push, sometimes though I receive push without additional data, but on notification tap app is crashing.
image

Attached log for both the cases:
OneSignal_notification_error_8th_march_on_tap.txt
OneSignal_notification_error_8th_march_on_receive.txt

@Dipannita20
Copy link
Author

@jkasten2

Even though I am sending Additional Data, but on NotificationWasOpened Additional Data is set to null
OneSignal.Default.NotificationWasOpened += _notificationOpened;
PXL_20220308_105138750 MP

Rawpayload looks like this:
PXL_20220308_105154454

@Dipannita20
Copy link
Author

@jkasten2
Xamarin.iOS versions above 15.4 and would suggest updating to the latest Xamarin version using the Visual Studio installer

I have installed Visual Studio 2022 on windows which has support for Xamarin.iOS and Xamarin.Mac SDK 15.6.0.3 (caa899d24) on pairing with Mac I was able to build app with Link Framework SDKs only, which is good. But without Additional Data app is still crashing and Additional data is set to null on notification payload. I am on latest 4.0.0-beta4. Cleaned up builds multiple times before testing. Please look into these issues

Microsoft Visual Studio Professional 2022
Version 17.1.1
VisualStudio.17.Release/17.1.1+32228.430
Microsoft .NET Framework
Version 4.8.04084

Installed Version: Professional

Azure App Service Tools v3.0.0 17.1.358.51495
Azure App Service Tools v3.0.0

C# Tools 4.1.0-5.22109.6+0c82c4114a4e4b8b723b915eee3b13261db6717f
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Extensibility Message Bus 1.2.6 (master@34d6af2)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Mono Debugging for Visual Studio 17.1.10 (65f98f5)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager 6.1.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

Visual Basic Tools 4.1.0-5.22109.6+0c82c4114a4e4b8b723b915eee3b13261db6717f
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 17.1.0-beta.21610.4+07b5673e4f2fa7630e78abe37f16b372353a7242
Microsoft Visual F# Tools

Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio IntelliCode 2.2
AI-assisted development for Visual Studio.

VisualStudio.DeviceLog 1.0
Information about my package

VisualStudio.Foo 1.0
Information about my package

VisualStudio.Mac 1.0
Mac Extension for Visual Studio

Xamarin 17.1.0.309 (d17-1@3f96c58)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer 17.1.0.87 (remotes/origin/main@d50fb5635)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates 17.1.8 (590388a)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK 12.2.0.4 (d17-1/19b97b7)
Xamarin.Android Reference Assemblies and MSBuild support.
Mono: a5d1934
Java.Interop: xamarin/java.interop/d17-1@7ac33610
ProGuard: Guardsquare/proguard@912d149
SQLite: xamarin/sqlite@0893b3b
Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-1@db125a7

Xamarin.iOS and Xamarin.Mac SDK 15.6.0.3 (caa899d24)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

@jkasten2
Copy link
Member

I have installed Visual Studio 2022 on windows which has support for Xamarin.iOS and Xamarin.Mac SDK 15.6.0.3 (caa899d24) on pairing with Mac I was able to build app with Link Framework SDKs only, which is good.

Good to hear this part is fixed for you!

But without Additional Data app is still crashing and Additional data is set to null on notification payload. I am on latest 4.0.0-beta4. Cleaned up builds multiple times before testing.

Thanks for confirming, we are looking at this on our end. We are looking to ship an update for this sometime next week.

@Dipannita20
Copy link
Author

@jkasten2
Thanks. There is one more issue, build is failing with OneSignalNotificationServiceExtension. I have followed
https://documentation.onesignal.com/docs/step-by-step-xamarin-3x-to-400-upgrade-guide. Build is failing on this line. This used to work with 3.10.6. Could please get this resolved in next beta or let me know if any changes needs to be done on myside

(OneSignal.Default as OneSignalImplementation).DidReceiveNotificationExtensionRequest(request, BestAttemptContent);

image
NotificationService.txt

@Dipannita20
Copy link
Author

There is one more issue, build is failing with OneSignalNotificationServiceExtension. I have followed https://documentation.onesignal.com/docs/step-by-step-xamarin-3x-to-400-upgrade-guide. Build is failing on this line. This used to work with 3.10.6. Could please get this resolved in next beta or let me know if any changes needs to be done on myside

Code update as per https://github.com/OneSignal/OneSignal-Xamarin-SDK/blob/4.0.0_release/Samples/OneSignalNotificationServiceExtension/NotificationService.cs resolve build issues related to OneSignalNotificationServiceExtension

@Dipannita20
Copy link
Author

@jkasten2 @tanaynigam

Thanks for confirming, we are looking at this on our end. We are looking to ship an update for this sometime next week

There is no update so far, any update on this?

@jkasten2
Copy link
Member

@Dipannita20 We are still working on the release, we will update you shortly.

@tanaynigam
Copy link
Contributor

@Dipannita20 We have a release OneSignalSDK.Xamarin-4.0.0-beta5 which should have a fix for the notification open crash. Please note that we have changed the package name and namespace for the SDK from Com.OneSignal to OneSignalSDK.Xamarin and would require you to remove the previous package name and add the new package name to import the SDK in your code.

Additionally, when searching for the package on nuget.org, you will be required to search for OneSignalSDK.Xamarin to import the package

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

3 participants