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

.Net9 causing Could not find the type 'ObjCRuntime.__Registrar__ #22071

Open
tj-devel709 opened this issue Jan 28, 2025 · 9 comments
Open

.Net9 causing Could not find the type 'ObjCRuntime.__Registrar__ #22071

tj-devel709 opened this issue Jan 28, 2025 · 9 comments
Labels
need-attention An issue requires our attention/response
Milestone

Comments

@tj-devel709
Copy link
Contributor


Issue moved from dotnet/maui#27312


From @natevarghese on Thursday, January 23, 2025 6:18:01 PM

Description

After updating all my projects to .NET 9, I encountered the following error when trying to access a custom Objective-C binding library, which is referenced by the iOS project. The issue only occurs on a physical iOS device:

Error:
Could not find the type 'ObjCRuntime.Registrar' in the assembly.

Following suggestions, I added the recommended configuration to one or more of the referenced projects, as described in the release notes:

Source: Xamarin .NET 9 Release Notes - Type Registrar

<Target Name="SelectStaticRegistrar" AfterTargets="SelectRegistrar">
  <PropertyGroup Condition="'$(Registrar)' == 'managed-static'">
    <Registrar>static</Registrar>
  </PropertyGroup>
</Target>

After making this change, the app crashes immediately on startup, preventing me from obtaining a stack trace. I'm unsure how to proceed. I’ve added the snippet to the iOS project, the binding library project(s), and every possible combination of them, but the issue persists.

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

9.0.0 GA

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

8.0.3 GA

Affected platforms

iOS

Affected platform versions

No response

Did you find any workaround?

No workarounds known

Relevant log output

@tj-devel709
Copy link
Contributor Author


Issue moved from dotnet/maui#27312


From @Ying-6 on Friday, January 24, 2025 9:09:39 AM

Could you provide a simple reproduction project for us to investigate it further? Looking forward to your reply!

@tj-devel709
Copy link
Contributor Author


Issue moved from dotnet/maui#27312


From @natevarghese on Saturday, January 25, 2025 10:10:52 AM

Please use this as a test repo. It has the objc bindings already so it's quite large but not a lot of code is required to reproduce it.
https://github.com/natevarghese/Solution1

As a reminder it only crashes on physical iOS devices, so you will need to update the bundle identifier to one you have provisioned.

@tj-devel709
Copy link
Contributor Author

Hi, moving the issue here. Let me know if this one should be in the Maui Issues!

@natevarghese
Copy link

Any update on this? Please do not archive it for inactivity

@Kalibrate-nvarghese
Copy link

@Ying-6 Any updates?

@rolfbjarne
Copy link
Member

Following suggestions, I added the recommended configuration to one or more of the referenced projects, as described in the release notes:

Source: Xamarin .NET 9 Release Notes - Type Registrar

Can you get an MSBuild binlog from the build of the main project (app project) with this workaround applied?

@rolfbjarne rolfbjarne added need-info Waiting for more information before the bug can be investigated and removed t/bug platform/iOS 🍎 labels Feb 10, 2025
@rolfbjarne rolfbjarne added this to the Future milestone Feb 10, 2025
@natevarghese
Copy link

@rolfbjarne

I generated msbuild.binlog using the following command:
dotnet build iOSApp1.csproj /bl:msbuild.binlog

The file has been added to the repository
https://github.com/natevarghese/Solution1/blob/master/msbuild.binlog

@microsoft-github-policy-service microsoft-github-policy-service bot added need-attention An issue requires our attention/response and removed need-info Waiting for more information before the bug can be investigated labels Feb 10, 2025
@rolfbjarne
Copy link
Member

This is probably a dup of #21891, which has already been fixed (and the fix was released a couple of weeks ago - https://github.com/xamarin/xamarin-macios/releases/tag/dotnet-9.0.1xx-xcode16.2-9173)

Can you try removing the workaround, updating to the latest version of the iOS workload, and then try again to see if that works?

@rolfbjarne rolfbjarne added need-info Waiting for more information before the bug can be investigated and removed need-attention An issue requires our attention/response labels Feb 13, 2025
@natevarghese
Copy link

Yes, updating to the latest workload solved it. Thanks!

@microsoft-github-policy-service microsoft-github-policy-service bot added need-attention An issue requires our attention/response and removed need-info Waiting for more information before the bug can be investigated labels Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-attention An issue requires our attention/response
Projects
None yet
Development

No branches or pull requests

4 participants