Xamarin 4.0 install problems : Drive F: Not found

I ran into some problems when installing the latest update to Xamarin 4. Whenever the installer popped up it would crash right after loading up and say something like “Drive F: not found”.

Now, to be clear, the source of this problem is not necessarily linked to the  Xamarin installer as this is known to happen to some installations going back all the way to Windows 7 and apparently it’s still happening now in Windows 10.

I don’t know what the exact reason is for this, but the good news is that I know the solution.

I suspect this has to do with bad unmounting of devices such as usb drives which makes msis confused when either trying to read the list of drives available or trying to pick a default. I would be very interested to hear from anyone who may be more knowledgeable on the matter.

In any case, I finally got around it by using the subst command. So here goes the solution:

Open a command prompt in Administrator mode. type :

subst [Drive letter causing the error]: “C:/Windows” 

Now open the installer and try again.

Reading a String From a Resources File in Asp.Net at RunTime

ok, at present, this information is as difficult to find on the web at the moment as it is stupidly simple.

if you google you most likely are going to come across solutions that new up a ResourceManager class based on a full namespace and an assembly name and most likely you may have run into problems.

If you all you are trying to do is load something from your statically defined Resources file in ASP.Net, all you need to do is use the static ResourceManager property like so:

var resourceManager = ResourceFileName.ResourceManager;
var text = resourceManager.GetString(“keyintheresourcefile”);

You can also get any other objects allowed in a Resources file besides strings such as files or images; you just have to call the right method on the ResourceManager object.

 

Orphaned Sql Server users

Sometimes when restoring SQL Server databases, particularly from one machine to another, you may end up with orphaned users. These are users who don’t have any log ins associated with them. This happens because usernames are stored internally against unique ids called SIDs which are generated much like GUIDs. If those ids don’t match then SQL Server can’t find the data associated with them, even if the usernames are the same.

In order to determine if you have any orphaned users, you can run this command against any given database:

EXEC sp_change_users_login 'Report'

Any users that come up are orphaned.

The good news is that you can execute a command to auto-fix them. The bad news is that this doesn’t always work.

The command to auto-fix them is :

EXEC sp_change_users_login 'Auto_Fix', 'user'

Just replaced user with the name of the user you want to fix.

This should work if the user already exists in the system and the user names match but the SIDs don’t; however, if the user needs to be created then you will need to issue the full command and give it a password like this:

EXEC sp_change_users_login 'Auto_Fix', 'user', 'login', 'password'

Just replace user with the name of the user that you need to fix such as those returned from the first query above, login with the username for the user and password with any given password (note that it may have to conform to your windows local password security policy)

 

XCode 7 : Adding a new device to an XCode-managed provisioning profile

Let me just start this post with a question : why is this still so hard?? Moreover, WHY does it only keep getting harder???

I don’t know what the XCode team are thinking, but the whole point of having your provisioning profiles managed by XCode is that it should make things simple and automagic. Well, not so.

Previous versions of XCode all had their quirks, but at least there was a refresh button that you could press that would reload and regenerate any provisioning profile if you, for instance, added a new device on the member center. Yes, a refresh button. easy right? Well, maybe they thought that was too easy so they decided to remove it.

As of XCode 7, supposedly, all profiles update automatically. Or do they?

I just added a new device to my member center, but it didn’t get added to my XCode-managed profiles. I restarted XCode and nothing. Then I stumbled upon a tip to actually delete the provisioning profiles then wait for XCode to regenerate them again and hit Dowload All. So I went to try to delete them, and guess what, as of the latest update XCode 7.0.1 (7A1001) the option to delete them is gone now. So you can try to right-click on them to your heart’s content and nothing will happen. sigh….I would scream if only it wasn’t so late at night already.

There is a solution, though I don’t consider it a solution at all, more like a brute force workaround:

Deploy a test app from XCode to your new device!

This will trigger XCode to then prompt you about the fact that there is no provisioning profile for that device installed and give you the “Fix Issue” button.

Click on “Fix Issue” and wait till the test app is deployed. I impatiently shortcut it right after clicking it and it still didn’t work, so all good things come to those who wait.

I can’t wait for XCode 8 now to see what is the next dumb thing the XCode team is going to do about this.

Sort it out already, Apple!

 

Windows 10 not recognizing Android devices for USB debugging

If you were able to deploy and debug just fine to your Android devices via USB before you upgraded to Windows 10, but now they just aren’t showing up, then it’s likely because of the way you are connecting them.

For no good reason that I have found so far, it seems like if you want to do USB debugging on Android devices in Windows 10 then you need to connected them as a Camera, yep that’s right, or n protocol terms, PTP.

Thanks, Microsoft. Not.

Xamarin Android : “aapt.exe exited with code 1.”

Sometimes Visual Studio craps out on us and gives some random errors which can be easily cleared out by restarting it. Unfortunately, this is not one of them.

If you see this error that means that genuinely something is breaking the Android packing process, even if the build may have succeed it.

This means there is not one single problem that causes this, but the good news is that it’s really easy to find out what the problem is.

It should be as easy as switching to your Output window and reading the log of all the steps up to when it failed.

This is the tricky part though. It may well be that you’ve even already done that but couldn’t find anything useful or the error message was too generic. Well then, what you are missing is that you have to set your MSBuild output to Normal verbosity. By default, it’s set to minimal.

In order to do that you go to Tools -> Options -> Projects and Solutions -> Build And Run then find where it says MSBuild project build output verbosity (on Visual Studio 2015 that’s a dropdow) and change it from Minimal to Normal if it isn’t set to that option already.

When I wrote this post my problem was that I named an image on the drawable folder with an illegal character in the file name.

Hopefully now you can find out what your problem is too 🙂

Implementing a Cross-Platform PDF Viewer in Xamarin.Forms and Android

In this post I’m going to show you how to implement a cross-platform PDF viewer using Xamarin.Forms. We are going to focus on  Android in this tutorial.

The approach we are going to take is to create a Dependency Service implementation on the Android project which triggers a choice for a external PDF viewing app on the user’s phone.

If you are wondering why not just use an embedded WebView to display PDFs, the short answer is that while it would work on IOS this wouldn’t work on any Android versions prior to Lollipop. Also, from a technical strategy and commercial point it may be more beneficial to allow the users freedom of choice. For more on that, you can read my previous blog post WebView Or External Web Picker? Or, When To Give Users Freedom .

Step 1 – Create the Dependency Service contract

On the PCL or SAP project Xamarin.Forms project, create the following interface:

public interface IPdfViewer
{
  void View(string filePath);
}

Step 2 – Create the Android implementation

On your Android project, create the following class:

public class PdfViewer : IPdfViewer
    {
        public void View(string filePath)
        {
            //copy to global
           
            var localFileStore = new LocalFileStore();
            localFileStore.CopyToGlobalStorage(filePath);
 
            Android.Net.Uri uri = Android.Net.Uri.Parse("file:///" + localFileStore.GetGlobalPath(filePath));
            Intent intent = new Intent(Intent.ActionView);
            intent.SetDataAndType(uri, "application/pdf");
            intent.SetFlags(ActivityFlags.ClearWhenTaskReset | ActivityFlags.NewTask);
 
            try
            {
                Xamarin.Forms.Forms.Context.StartActivity(intent);
            }
            catch (Exception)
            {
                Toast.MakeText(Xamarin.Forms.Forms.Context, "No Application Available to View PDF", ToastLength.Short).Show();
            }
        }
    }