newrelic / newrelic-maui-plugin

New Relic Mobile instrumentation for MAUI
Apache License 2.0
9 stars 5 forks source link

Exception in CrossNewRelic.Current while try to run on iOS. #48

Open SuryaCheran opened 1 month ago

SuryaCheran commented 1 month ago

I have followed the steps in Read.me and when I tried to run the iOS app I'm getting exception as "This functionality is not implemented in the portable version of this assembly. You should reference the NuGet package from your main application project in order to reference the platform-specific implementation." Note : Issue is only on iOS

if IOS

         AppLifecycle.AddiOS(iOS => iOS.WillFinishLaunching((_,__) => {
            StartNewRelic();
            return false;
        }));
    private static void StartNewRelic()
    {
        try
        {
            CrossNewRelic.Current.HandleUncaughtException();
            CrossNewRelic.Current.TrackShellNavigatedEvents();

            // Options are: crashReportingEnabled, loggingEnabled, logLevel, collectorAddress, crashCollectorAddress,analyticsEventEnabled, networkErrorRequestEnabled, networkRequestEnabled, interactionTracingEnabled,webViewInstrumentation, fedRampEnabled,offlineStorageEnabled,newEventSystemEnabled,backgroundReportingEnabled

            AgentStartConfiguration agentConfig = new AgentStartConfiguration(true, true, NewRelic.MAUI.Plugin.LogLevel.INFO, interactionTracingEnabled: false, backgroundReportingEnabled: true);

            if (DeviceInfo.Current.Platform == DevicePlatform.Android)
            {
                CrossNewRelic.Current.Start("MY_TOKEN-android", agentConfig);
            }
            else if (DeviceInfo.Current.Platform == DevicePlatform.iOS)
            {
                CrossNewRelic.Current.Start("MY_TOKEN-iOS", agentConfig);
            }
        }
        catch (Exception ex)
        {
        }
    }
}

NewRelic_Issue

Steps to Reproduce

ndesai-newrelic commented 1 month ago

@SuryaCheran you should invoke "CrossNewRelic.Current.TrackShellNavigatedEvents();" after creating the AppShell of the app.We will update our documentation to clarify this. we are unable to reproduce the issue from our side.

SuryaCheran commented 1 month ago

Hi @ndesai-newrelic , I have tried it as per your suggestion but the issue is still there. Any Other Alternative workarounds ? Note : I have installed the latest Nuget Package.

ndesai-newrelic commented 1 month ago

@SuryaCheran can you share your example app for this?

vikashhd commented 1 month ago

We are also getting same exception. Nothing special we are using same code that you provided in example. Env is .Net 8 ios

With same code we are able to open our app with Relic version 1.0.0 But getting exception for >1.0.0

ndesai-newrelic commented 1 month ago

@vikashhd can you share sample app for this?

SuryaCheran commented 1 month ago

Hi @ndesai-newrelic , Sorry for the delay . I couldn't able to upload the sample app because of size restriction.. Still Im experiencing the same issue. I might doubt NewRelic.MAUI.iOS.Binding is not installed properly..But I have the reference in project file. Is there any possibility like this ? Note : Currently I have installed to Nuget package via VSCode and even I tried to install NewRelic.MAUI.iOS.Binding in Windows but i faced a path error as System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\surya.cheran.nuget\packages\newrelic.maui.ios.binding\7.5.2\lib\net8.0-ios18.0\NewRelic.MAUI.iOS.Binding.resources\NewRelic.xcframework\ios-arm64_x86_64-simulator\NewRelic.framework\Modules\NewRelic.swiftmodule\arm64-apple-ios-simulator.private.swiftinterface'.

Nuget Package Installed: 1.NewRelic.MAUI.iOS.Binding Version ="7.5.0" 2.NewRelic.MAUI.Plugin Version="1.1.3"

image .

ndesai-newrelic commented 1 month ago

@SuryaCheran this is known issue and we cant do anything from our side. https://github.com/newrelic/newrelic-maui-plugin/issues/24

bennoschoonraad commented 1 week ago

I also run into this issue with NewRelic.MAUI.Plugin Version 1.1.4. when using GetHttpMessageHandler. As an example: image

When running the application for iOS - the application crashes with the error:

An error occurred: 'This functionality is not implemented in the portable version of this assembly. You should reference the NuGet package from your main application project in order to reference the platform-specific implementation.'. Callstack: '   at NewRelic.MAUI.Plugin.CrossNewRelic.get_Current()

This was not an issue in version 1.1.0 of the NewRelic.MAUI.Plugin.

Update

Including the following package (and the Android equivalent) in my project's .csproj seemed to resolve the issue. image