If you’ve ever wanted a light coloured text status bar, you may have experienced difficulties. If you have the current VS Plugin with current being (in iOS 8.1), Xamarin Studio 5.5.3. My VS plugin 8.4.0.0 and Windows Xamarin 3.7.23.0, then you’ll see you don’t have the choice of picking it in the info.plist editor. The choices are Default, Black Transparent and Black Opaque.

Those last two choices are now deprecated and there should be a Light Content. This changed in iOS 7.0 (see the iOS 7.0 transition guide).

For the fixes, I recommend that you edit info.plist with anything but the VS plugin, at least until they fix it. I use programmers notebook 2 which is excellent.

You need to add the following lines in info.plist:

	<key>UIViewControllerBasedStatusBarAppearance</key>
	<false/>

and in AppDelegate.cs you need to add the following line. I’ve shown it bold and in my code I’m using Tabs so create a Tab Controller (my own class) rather than the usual UIViewController.

            tabController = new TabController();
    UIApplication.SharedApplication.SetStatusBarStyle(UIStatusBarStyle.LightContent, false);
	    UIApplication.SharedApplication.SetStatusBarHidden (false, false);
            window.RootViewController = tabController;
            window.MakeKeyAndVisible();
            return true;

If you have a launch image you’ll probably want the status bar hidden during launch. If you had previously ticked the hide during application launch checkbox, it adds the following into info.plist.

	<key>UIStatusBarHidden</key>
	<true/>

What this also does with the Light Content fix is keep the status bar hidden so add the second line above (SetStatusBarHidden) as well to unhide it.

To try this fix out, download the code from here :Xamarin Sample for Tab Bars.

Next change the TabBarController so a tab or two is displaying dark colours.

			tab1 = new UIViewController();
			tab1.Title = "Gray";
			tab1.View.BackgroundColor = UIColor.Gray;

and add the one or two lines above to AppDelegate.cs

I guess I’ll never know what actually caused this but renaming the project then creating a new one from scratch, adding everything back in and rebuilding it did the trick!

Over the years I’ve seen this type of thing happen once or twice. Visual Studio .sln files etc can be quite hairy and when something like this occurs, it’s often the easiest way.

I added Default.png and the other variations for iPhone 5, retina display fils and they appeared in the Resources folder. These are for loading screens and are built in as part of the bundle after you add them.

However in doing some work on rolling my own Splash screen so it can have text added, I decided to remove them.

In Xamarin Studio (on Mac) you can unset them, but compiling gave 2 errors about missing files. Looking in the info.plist on the source tab revealed that two strings were still there so I manually removed those. I did a clean then a Build and still got the errors. I did a clean and a Rebuild and still got the same errors. Finally I closed Xamarin Studio down, then reopened it and it built fine. Just a minor irritation.

My App talks to a server over TCP/IP using a well defined packet protocol but I’d been experiencing difficulties of the “packets seem the wrong length” type. I got the server author to debug a conversation.

Now the server sends extra bytes in the middle of messages depending upon the server version of the Client App talking to it. I found this out early on. Anything under version 43 and it omitted two bytes in the middle of the packet.

My App was set to version 200. Androids start at 100, Windows Phone (the first App was created for it) start at 0. The version number is sent as a five char string with leading 0’s so my App sends 00200. It turned out that the part of the server that verified and classified messages only checked the last two digits. D’oh!

Hence my server seemed to be version 0. Until the bug is fixed, my App is now version 00260.

Failed-dissassemble

Occasionally I’ll get a crash that needs Visual Studio 2012 to be restarted and just now and then I get a Catastrophic failure Exception 0x8000FFFF (E_UNEXPECTED) at EnvDTE.Command.AddConrol at Sil.VSCommon.SilAddInstance.CreateUserInterface(). Once a week or less frequent.

I suspect it’s the Xamarin Plugin, but it might not be so has anyone else seen this?

The answer is just to restart VS.

I’ve noticed that if I’m away from my PC for a while (generally over an hour), Visual Studio loses the connection to the Mac Build Host. When I try to reconnect via the Visual Studio Tools/Option/Xamarin/iOS Configure button, it won’t reconnect. The Mac build host is shown as unreachable and Diagnose fails trying to talk to the Mac.

Restarting Visual Studio doesn’t do it, you have to close down then reopen Xamarin Studio. It’s 4.0.12 (build 3). Then you can reconnect from Visual Studio. Not a big bug, just a minor PITA!

One of the nice things about Visual Studio 2012 is the Code Analysis. It’s worth doing to try and find underlying problems and I found some in mine. The code worked fine, but Code Analysis told me I was doing naughties with a Virtual Method in a constructor.

Mea culpa. I was indeed. I’d created a View object with my Subclassed View in a CustomViewController.

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View = new MainView(UIScreen.MainScreen.Bounds);
        }

But I’d been doing all sorts in the MainView() constructor that needed not to be there, though it had seemed to run ok. If configuration data is absent I want to stop things and have it entered. So I was creating SubViews (Controls) and then calling the UIView.AddSubView() that MainView inherited from within the Constructor. Shock Horror Probe! Bad Code Alert…

The risk is that a virtual method may not have been correctly assigned and the compiler doesn’t really like Constructors in C# to have to worry about this. After a Constructor has finished, things should be just swell.

The trick is to move the code into a subclassed ViewController.ViewWillAppear(). This is called whenever the View is about to appear. Use a bool variable to let things that should be initialized here just the once be only called just the once.

        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);
            if ((View as MainView).ConfigCheck() && OneOff)
            {
                OneOff = false;
                // one off code here
            }
        }

This is on Windows 7 and happens every day if I don’t start the Xamarin Bonjour service before Visual Studio and opening a Xamarin.iOS project. It’s not that big a deal but something must be switching the Xamarin Bonjour Service from Automatic. I set it to automatic a few times but it gets reset to Manual. Once it’s running it stays running for the rest of the day.

bonjour-initialization-failure


If you get this make sure the Bonjour Service is running. If it’s not, open the services MMC. You can do this from Task Manager but make sure on the Processes tab you click the Show processes from all users button as the service may not start. Then on the services Tab in Task Manager, at the bottom right then when the Services MMC opens scroll to the bottom. If you don’t see Started then right click on the service and click Start.

bonjour-service

Hopefully you should be able to select iPhone 6.1 in the combo box and all will be well. If not see this tip on Visual Studio to Mac Connectivity.