VS2013: An exception has been encountered. This may be caused by an extension.

Hey peeps,

Ever gotten the nice error dialog when opening your Visual Studio saying something like: “An exception has been encountered. This may be caused by an extension. You can get more information by bexamining the file ~AppDataRoamingMicrosoftVisualStudio12.0ActivityLog.xml”?

Then after reading that, you think “OK, lets check it out. Might be some useful information there”.

Opening up the ActivityLog.xml you’ll probably notice that your assumption might have been slightly off base:

System.IO.IOException: The file exists. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.__Error.WinIOError() at System.IO.Path.InternalGetTempFileName(Boolean checkHost) at Microsoft.VisualStudio.Text.Utilities.WpfHelper.LoadCursorDPIAware(Stream cursorStream) at Microsoft.VisualStudio.Text.Editor.Implementation.LeftSelectionMargin.get_RightArrowCursor() at Microsoft.VisualStudio.Text.Editor.Implementation.LeftSelectionMarginProvider.CreateMargin(IWpfTextViewHost textViewHost, IWpfTextViewMargin containerMargin) at Microsoft.VisualStudio.Text.Utilities.ContainerMargin.<AddMargins>b__2(IWpfTextViewMarginProvider mp) at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.InstantiateExtension[TExtension,TMetadata,TExtensionInstance](Object errorSource, Lazy2 provider, Func2 getter)

Boom! Now what to do with that? Turns out this indicates that Visual Studio or some extension has difficulties creating files/folders in your Temp folder, because it is full! Full being it has over 65535 files/folders in it. Cleaning up the temp folder will do the trick, and also save you some space. In my case I had 4 GB of crap laying around. (Where did all that come from and why weren’t it deleted automatically?).

Oh, your Temp folder is probably located here: C:UsersYOURUSERNAMEAppDataLocalTemp.

Have fun!

Xamarin iOS: Build host too old?

Hey guys,

I just wanted to post a quick tip a way to resolve the error “The build host is too old for this version of Xamarin.iOS extension” in Visual Studio. This seems to occur if you recently set up a proxy of some sorts or have installed a tool like Fiddler.

I had just installed Fiddler to capture HTTP packets for monitoring my requests and responses when communicating with a back-end. Turns out Fiddler had enabled a proxy of a sort that disrupts the Xamarin Build host connection into thinking that the build host is too old.

Opening up Fiddler and turning off all the Proxy-settings I could find, the connection was fixed and I could build again. Happy days.


Want to learn C# and Windows (Phone) development?

The best inspiration for writing blog posts is absolutely the questions I receive from people via Facebook, Twitter, E-mail and more. For this particular post the question at hand was if I had any good resources for learning to code and develop applications in C#.

How one learn is different for each person. Someone needs to have hands-on tutoring, visual/audio-based material and of course reading. However; the only way to truly learn is by doing and practicing. If you are the one who needs hands-on tutoring then I might suggest you look up courses near you, as I can’t help you there. In this post I have tried to come up with some good video walkthroughs and reading material for each category, so continue reading to get to the good stuff.

Design and develop with sample data

When developing an application it is often time consuming having to deploy the application to a device or the emulator to see how a specific view or template might look like with real data. This is where sample data comes in handy. Using the design-time tools available to us in Visual Studio and XAML we can inject sample data to our views.

Creating the sample data

In this example application we’re using the MVVM-pattern for structuring our code, and we have a viewmodel named MainPageViewModel that we want to mock up. The MainPageViewModel contains a collection of MenuItems that is populated at run-time. The view (PhoneApplicationPage in this example) contains a ListBox that binds to that collection. To see what a MenuItem will look like when running an app, we can bind the view to a sample instance of the MainPageViewModel. Fortunately, all of this can be done using XAML.

The first step is to create a new XAML file. In this example it’s called MainPageViewModelSampleData.xaml and is placed under a fictious folder named SampleData:

The code above shows the contents of the sample data for our MainPageViewModel. The XAML is pretty self-explanatory: we first create a new instance of MainPageViewModel and can manipulate all of its properties using XAML. The MenuItem collection is easily populated with MainPageMenuItems, which contains a Title property we’re setting.

Using the sample data

To use our XAML sample data we can tell our view to use it as a source for DataContext during design-time:

After setting the DataContext property you will (hopefully) immediately see the ListBox containing our sample items. This is extremely useful when crafting views and item templates.

If you have any questions regarding using sample data, please feel free to comment below and I will try to answer as best I can.

Thank you for reading.