0
Fixed

Results view shows error

Steve Miller 5 months ago • updated 5 months ago 2

After returning from the TestIt method looking at the Results View shows a stop sign with an Error for the following code running in Visual Studio 2017 with Framework 4.5.2:


using System;
using System.Collections.Generic;

namespace TestNetControlApp
{
    class Program
    {
        public static IEnumerable<string> TestIt(string text)
        {
            var arr = text.Split(' ');


            foreach (var str in arr)
            {
                yield return str;
            }
        }


        static void Main(string[] args)
        {
            var a = TestIt("Item0 Item1 Item2 Item3");


            // Looking at results view for a shows error


            foreach (var s in a)
            {
                Console.WriteLine("{0}", s);
            }

            Console.ReadLine();
        }
    }
}


Fixed

Hi Steve. Thanks for the report! As it turns out, I just tested this and the problems occurs just the same on an instance of Visual Studio that does not have OzCode installed. As such, you may want to report this issue on the Microsoft feedback page.


FYI - the problem occurs because enumeration the Results View requires the System.Threading.Thread type to be already loaded into your application. Thus, if you were to add the line of code "var myThread = Thread.CurrentThread.ManagedThreadId;" to your console app (for example, as the 1st line of Main()), that will solve the problem for you.


Hope this help!

Thanks for the prompt reply Omer :) I disabled OzCode and saw the same results, but was not sure if somehow OzCode was influencing the results. That's interesting about the thread type. I tried it out and it worked great! I'll send Microsoft some feedback. Thanks again :)