Tuesday, 4 November 2014

Downgrading from Visual Studio 2013 Premium to Professional - The easy way

Visual Studio


Due to a miss-understanding of the MSDN Subscriber download site, I accidentally downloaded and sequentially used up the trial of Premium. This was a really annoyance as the internet I am currently on doesn't take to kindly to downloading 600mb .iso's. It was going to take 12+ hours to complete!

This was unacceptable as I had work I had to get done. So I tried the other option, the web installer (traditionally I avoid these as I am a hoarder of installers so I don't have to re-download). This is where the awesomeness happened... It didn't have to download anything! (well at least it doesn't look like it had to) on the installer, the acquiring progress bar when through allot faster than it should have and it only took 10-20 minutes to install, which from previous memories is the same install time as via the .iso!

This speed increase (from 12+ hours to 20 minuets) could be caused by either:
A. The network policies favor the method the web installer used (don't think so)
B. The download speed on the .iso from Microsoft is capped at 100kb/s (I hope not)
OR
C. It re-used my premium's install data to not have to download everything again (What I think happened as it downloaded to the same folder as Premium and I couldn't launch it until I uninstalled Premium)

Then all I had to do was uninstall Premium from my Add and Remove Programs (both Premium and Professional showed up) then enter my key given via the MSDN Subscriber portal and BAM! I had my Visual Studio up and running again. Also, as an extra spurt of luck, I didn't loose my recent projects. This is only a small thing, but I really was dreading un-installing and potentially loosing my file history.

I would love to hear in the comments from anyone else who was having this problem and if my solution had the same outcome for them. Or if you know how the web installer works, maybe either confirm or deny my theory.

Thanks for reading!

Monday, 3 November 2014

Quick and easy Console Logging - Trace

trace

Just a quick Blog,

I was wanting to get the output of my Console Write to a log file but still show to the Console!! So off to google I went and I found this amazing solution via StackOverflow!

I thought that I would pass on the love with a slightly modified (cleaned up and simplified the output location)

      /// <summary>  
      /// Initiates a Tracer which will print to both  
      /// the Console and to a log file, log.txt  
      /// </summary>  
      private static void InitiateTracer()  
      {  
        Trace.Listeners.Clear();  
        var dir = AppDomain.CurrentDomain.BaseDirectory;  
        var twtl = new TextWriterTraceListener("log.txt")  
        {  
          Name = "TextLogger",  
          TraceOutputOptions = TraceOptions.ThreadId | TraceOptions.DateTime  
        };  
        var ctl = new ConsoleTraceListener(false) { TraceOutputOptions = TraceOptions.DateTime };  
        Trace.Listeners.Add(twtl);  
        Trace.Listeners.Add(ctl);  
        Trace.AutoFlush = true;  
      }  

The next step is to use replace (ctrl+h) on 'Console.Write(' with 'Trace.Write(' and 'Console.WriteLine(' with 'Trace.WriteLine('. After this it probably will not build, that will be because you need to add 'using System.Diagnostics;' to the top of the pages where you replace Console with Trace. The next error you might get is a bit less likely. If you have been using Console.WriteLine's build in String.Format you will have to add String.Format yourself as Trace doesn't do it automagically :(

Then simply call InitiateTracer() from within your Console Applications main and voilĂ  you have your normal console output + output to a log.txt file in the same path as your executable so you can check over your logs at a later time!

Hope this helps :) Thanks once again to