public static void SetLocation(Application app, ProductException ex, MethodDefinition method, Instruction instruction = null)
        {
            if (!method.HasBody)
            {
                return;
            }

            if (instruction == null && method.Body.Instructions.Count == 0)
            {
                return;
            }

            if (instruction == null)
            {
                instruction = method.Body.Instructions [0];
            }

            app.LoadSymbols();

            if (!method.DebugInformation.HasSequencePoints)
            {
                return;
            }

            // Find the sequence point with the highest offset that is less than or equal to the instruction's offset
            SequencePoint seq = null;

            foreach (var pnt in method.DebugInformation.SequencePoints)
            {
                if (pnt.Offset > instruction.Offset)
                {
                    continue;
                }

                if (seq != null && seq.Offset >= pnt.Offset)
                {
                    continue;
                }

                seq = pnt;
            }
            if (seq == null)
            {
                return;
            }

            ex.FileName   = seq.Document.Url;
            ex.LineNumber = seq.StartLine;
        }