CameTooFar

A Nerd's False Positive.

Fix: Unity3d InputText foreground color white in Android

Last week, I was creating an Android app using Unity. However, when I deployed the app to device, I noticed that foreground color of input control is in white color but renders as expected in Unity editor and in other platform targets.


unity-droid-foregroundcolor

Add the below style in AndroidManifest.xml file and the issue will be resolved.

android:theme="@android:style/Theme.NoTitleBar"

Thanks.


Add GUID as primary key column in code-first migration

Last week, I was migrating an old ASP.NET MVC project and as part of that I decided to replace the identity column from auto-incremented numeric value to GUID values which looks more professional.

Below are the changes that you need to make to achieve this.

// in your model class.
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public Guid Id { get; set; }


Run, Add-Migration command which generates your migration class and make below change:

// in your migration class.
AlterColumn("dbo.LoLChampionPickeds", "Id", c => c.Guid(nullable: false, identity: true, defaultValueSql: "newsequentialid()"));

That's it. Now do an Update-Database and your Id field will start using GUIDs.

Thanks.

Fix: The located assembly's manifest definition does not match the assembly reference

Got the below error message ever?

The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I know how frustrating that is.

One of my team member added JSON.NET via nuget and all of a sudden all other devs start getting the above error message while invoking any methods from JSON.NET. I tried a dozen workaround that I got while searching for solution but none of them worked. After careful, time consuming analysis I figured out the issue. Our project was referring few PCL projects which was provided by client. All those projects were referring JSON.NET v6.0.3. Yay! That’s an old stable working client library. I uninstalled JSON.NET v9 and installed v6.0.3 which fixed the issue.

However, what still surprises me is why the dev who added v9 library not getting any error while others devs are getting the error? Weird.

Thanks.