问题
I want to debug a Xamarin.Forms app on an Android device. If I set a breakpoint I get this error message from Visual Studio:
This is the output of the console
Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.
System.ArgumentException: Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.
at System.Buffer.BlockCopy(Array src, Int32 srcOffset, Array dst, Int32 dstOffset, Int32 count)
at Mono.Cecil.Metadata.GuidHeap.Read(UInt32 index)
at Mono.Cecil.MetadataReader.InitializeCustomDebugInformations()
at Mono.Cecil.MetadataReader.GetCustomDebugInformation(ICustomDebugInformationProvider provider)
at Mono.Cecil.Cil.PortablePdbReader.Read(MethodDefinition method)
at Mono.Cecil.Cil.CodeReader.ReadMethodBody()
at Mono.Cecil.Cil.CodeReader.ReadMethodBody(MethodDefinition method)
at Mono.Cecil.MethodDefinition.<>c.<get_Body>b__41_0(MethodDefinition method, MetadataReader reader)
at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TRet& variable, TItem item, Func`3 read)
at Mono.Cecil.MethodDefinition.get_Body()
at Mono.Cecil.MethodDefinition.get_DebugInformation()
at Mono.Debugging.Soft.SoftDebuggerSession.LoadPdbType(TypeDefinition type, Dictionary`2 fileToSourceFileInfos)
at Mono.Debugging.Soft.SoftDebuggerSession.LoadPdbFile(String assemblyFileName, String pdbFileName)
at Mono.Debugging.Soft.SoftDebuggerSession.LoadDebugFile(String assemblyFileName, String debugFileName, Func`3 loadDebugFile)
at Mono.Debugging.Soft.SoftDebuggerSession.CheckBetterMatch(TypeMirror type, String file, Int32 line, Int32 column, Location found)
at Mono.Debugging.Soft.SoftDebuggerSession.FindLocationByMethod(MethodMirror method, String file, Int32 line, Int32 column, Boolean& insideTypeRange)
at Mono.Debugging.Soft.SoftDebuggerSession.FindLocationByType(TypeMirror type, String file, Int32 line, Int32 column, Boolean& genericMethod, Boolean& insideTypeRange)
at Mono.Debugging.Soft.SoftDebuggerSession.ResolveBreakpoints(TypeMirror type)
at Mono.Debugging.Soft.SoftDebuggerSession.HandleTypeLoadEvents(TypeLoadEvent[] events)
at Mono.Debugging.Soft.SoftDebuggerSession.HandleEventSet(EventSet es)
at Mono.Debugging.Soft.SoftDebuggerSession.EventHandler()
If I don't set any breakpoints the app seems to work normally. Is there something wrong in my code? I'm using the latest Xamarin.Forms (2.3.4.247).
回答1:
Seems that using portable as DebugType was causing these issues. Now I reverted it back to full and it seems to work for now.
来源:https://stackoverflow.com/questions/45632836/cant-set-use-breakpoints-anymore-when-debugging-on-android-device