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

NullReferenceException at Microsoft.ApplicationInsights.Extensibility.Implementation.GetStackFrame #819

Closed
abhimanyusinghal opened this issue May 28, 2018 · 1 comment
Labels

Comments

@abhimanyusinghal
Copy link

I am using Microsoft.ApplicationInsights in a .NET Core dll.

I am unable to create an Instance of ExceptionTelemetry as it throws a NullReferenceException.

Upon further investigation I found:
On Xamarin Android the Exception contains a System.Diagnostics.StackFrame as
" {< unknown method > at < unknown offset > in file:line:column :0:0} "

Following Method is throwing Exception:
Microsoft.ApplicationInsights.Extensibility.Implementation.GetStackFrame

internal static External.StackFrame GetStackFrame(StackFrame stackFrame, int frameId)
        {
            var convertedStackFrame = new External.StackFrame()
            {
                level = frameId
            };

            var methodInfo = stackFrame.GetMethod();
            string fullName;
            if (methodInfo.DeclaringType != null)
            {
                fullName = methodInfo.DeclaringType.FullName + "." + methodInfo.Name;
            }
            else
            {
                fullName = methodInfo.Name;
            }

            convertedStackFrame.method = fullName;
            convertedStackFrame.assembly = methodInfo.Module.Assembly.FullName;
            convertedStackFrame.fileName = stackFrame.GetFileName();

            // 0 means it is unavailable
            int line = stackFrame.GetFileLineNumber();
            if (line != 0)
            {
                convertedStackFrame.line = line;
            }

            return convertedStackFrame;
        }

Exception raised from my code which I am trying to report to Application insights contains following stack trace:
at Xamarin.Forms.Xaml.CreateValuesVisitor.Visit (Xamarin.Forms.Xaml.ElementNode node, Xamarin.Forms.Xaml.INode parentNode) [0x00040] in D:\a\1\s\Xamarin.Forms.Xaml\CreateValuesVisitor.cs:50
at Xamarin.Forms.Xaml.ElementNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x000ac] in D:\a\1\s\Xamarin.Forms.Xaml\XamlNode.cs:149
at Xamarin.Forms.Xaml.ElementNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x00079] in D:\a\1\s\Xamarin.Forms.Xaml\XamlNode.cs:145
at Xamarin.Forms.Xaml.RootNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x00044] in D:\a\1\s\Xamarin.Forms.Xaml\XamlNode.cs:200
at Xamarin.Forms.Xaml.XamlLoader.Visit (Xamarin.Forms.Xaml.RootNode rootnode, Xamarin.Forms.Xaml.HydrationContext visitorContext) [0x00054] in D:\a\1\s\Xamarin.Forms.Xaml\XamlLoader.cs:140
at Xamarin.Forms.Xaml.XamlLoader.Load (System.Object view, System.String xaml) [0x00058] in D:\a\1\s\Xamarin.Forms.Xaml\XamlLoader.cs:89
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in :0

Upon further investigration

Looks like on Xamarin Android, Stack Information contains lines which do not have method information and hence GetStackFrame is throwing an Exception.

Version Info

SDK Version : 2.5.1
.NET Version : .NET Standard 2.0
Xamarin Android Version: 8.2.0.16

@lmolkova lmolkova added the bug label Jun 7, 2018
sandyarmstrong added a commit to sandyarmstrong/workbooks that referenced this issue Jun 26, 2018
sandyarmstrong added a commit to sandyarmstrong/workbooks that referenced this issue Jun 27, 2018
TimothyMothra pushed a commit that referenced this issue Oct 25, 2019
* Update base and web to 2.9.0-beta3 and update version

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

No branches or pull requests

2 participants