24 November, 2014

Visual Studio: where has my Intellisense gone?

Man, a life without Intellisense is a heavy one. Growing used to rely on Intellisense when programming in Visual Studio – life is difficult when it suddenly decides to stop working.

Luckily, I found a way around this. Basically, it’s just a reset of VS settings which actually also fixes the missing Intellisense.

  • Tools
  • Import and Export settings…
  • reset all settings
  • DONE

26 July, 2014

FIX: Nokia 930 and faulty zoom?

Man, having bought a crispy new phone from my preferred manufacturer I was all excited. That excitement lasted only for so long as I quickly learned of the troublesome pinch/zoom functionality of the screen. Hell – my old Nokia 925 was way better. This one responded instantly in contrast to the case with my brand new Nokia 930!

What is the problem? Well – who should have known that this particular phone comes with a setting that makes the screen quite unresponsive? Once you know and turn that off – your phone works the way it should work, namely instantly!

TURN OFF THE SCREEN MAGNIFIER!

wp_ss_20140726_0001

24 July, 2014

Install an assembly to GAC on Win2012

Man, things are never static!

One used to be able to just drag/drop an assembly into the assembly gac to have it installed. Say hello to Windows Server 2012 and this is no longer an option? So without having to install all sorts of development tools or other stuff – you can use PowerShell to perform this action. I can’t think of any other way of doing it actually.

1. Open a PowerShell command prompt and enter the following
(note that your lines are the $publish.GacInstall(“<full path to my assembly>”))

image

2. Run this from an elevated admin PowerShell console

3. Done.

25 June, 2014

InternalsVisibleTo: PublicKey-extraction

So Microsoft, why does it have to be so unnecessary difficult to setup a InternalVisibleTo attribute on an assembly? Your tooling is really not making it easier, although they are there hidden (sn.exe).

So, to cut to the bone. To extract the full public key and not only the Public Key Token which is kind of a shorthand for the public key, you need to use the sn.exe tool.

1) Open a developer admin command prompt (admin)

2) Type sn.exe –Tp <name of your signed dll> > key.txt (note the  -Tp switch)

3) You will find the public key as well as the token in the text file (key.txt)

In the below the ‘> key.txt’ pipe is not shown, but merely for the purpose of this blog post.

image

4) Insert the value into the assemblyinfo.cs like this:

5) [InternalsVisibleTo(“<assemblyname>, PublicKey=<long number>”)]

Technorati Tags:

23 June, 2014

FIM 2010 - SQL MA: Setting up multi-valued tables

Experience tells me that setting up the combination of a multi-value table and the FIM 2010 SQL MA calls for some extended documentation and walkthrough. The documentation on the FIM 2010 product once again excels in it’s level of (lack of) quality.

So – let’s cut to the bone straight away. I have a table that holds all my Staff, but with singular values only for all properties. Let’s for the sake of this walkthrough agree that I wish to provide all staff with the option of filling more than one job function at the same time. This calls for a multi valued field called JobFunction.

I wish to be allowed to model this situation in my database (source) as well as in my FIM 2010 MV (MetaVerse). Let’s start with the source system (the database) then move on the the FIM 2010 part of things.

External System: Database (source)

Below is the main table (left) and the secondary table (right). The left table holds all single value fields whereas the right will hold all fields on a (referenced) user that can take multiple values.

image                           image

The same tables are seen below with data.

image

image

The key to all of this modeling is that the secondary table needs to have 3 columns only. A reference [employeeID] to the staff in question (CA0000011), the name of the attribute [AttributeName] this row describes (JobFunction) and the value of this attribute [AttributeValue] (Janitor, Sales Rep…).

In more pragmatic terms the above means that the staff member (CA000011, John Carpenter) has 3 job functions namely Janitor, Sales Rep. and Teacher.

With this in place we can set up FIM 2010 to understand this model.

FIM 2010 (SYNC):

First of – we need to set up a field on the Person object in the metaverse to receive these incoming multi values. This fields I’ll call JobFunction and mark it as multivalued.

First – setup the user (Person) with a property of type string and multivalued.

image

Setup of the MA: the name of the table (tblStaffMultiValues) that holds the multivalue fields.

image

Press “Multi-value” on the Columns page.

image

Here is the key to all of this: The dropdown control should hold the NAME of the database table column that holds the property Name. In my case this is the AttributeName column (value = JobFunction).

Next is the column that holds the value. Only string types are supported so only one option there. This dropdown should hold the NAME of the database table column that holds the property Value. In my case this is the AttributeValue column (values = Janitor, Sales Rep…)

image

Finally – upon import and sync of data you should see a Person with a multivalue JobFunction as per below.

image

That’s how (easy?) it is to setup the multivalue thing on the FIM SQL MA.

19 June, 2014

TFS: Failed to backup

I have for some time been having problems with the regular backup function of the team foundation server. The error was related to some xml-error that was quite strange to me.

image

It turns out the issue was that the system writes a dictionary of existing backups present at the backup location (where the files are copied to). In that location, a file exists called Backupsets.xml. In my case, opening that file certainly proved it was corrupted (invalid XML).

So what to do…? As I did not want to edit this file by hand as it is all sorts of GUID references to stuff, the thing that made it work for me was to actually delete quite a number of the backups from disk and regenerate/setup the backup schedules from within the Team Foundation Server Administration Console. Before you say – “hey, that kind of contradicts the whole idea of having backups?”. Yes – that is correct, but as I’m running full backups on a daily basis that’s not a problem for me. I can always restore the databases to any day of the week as this full back is running daily.

Technorati Tags:

12 May, 2014

Download file from OneDrive: Solved

I’m lost for words with the lack of documentation for using OneDrive from a Windows Phone 8.1 application. I has literally taken me days to get this one to work! Finally, a comment on a forum somewhere guided me in the right direction.

How do you download the content of a file found on your OneDrive? If you just use the poor samples at MS webpage, you gain the metadata of the file you are downloading. Not the content which is what you are after (or I was!).

Downloading a file (content!) from a OneDrive folder is done in the following way.

1) Establish a session with OneDrive

 public async Task<LiveConnectSession> Initialize()
{
LiveAuthClient auth = new LiveAuthClient();
var r = await auth.InitializeAsync(new string[] { "wl.skydrive_update"});
return r.Session;
}
2) Download the file (important is the “/content” as id)
   public async Task<IStorageFile> LoadFile(string fileId)
{
//temporary file for write
var fileTmp = await ApplicationData.Current.LocalFolder.CreateFileAsync("tmp.xml", CreationCollisionOption.ReplaceExisting);

var session = await Initialize();
var liveClient = new LiveConnectClient(session);

//add /content to get the content of the file instead of the metadata.
await liveClient.BackgroundDownloadAsync(fileId + "/content", fileTmp);

return fileTmp;
}

3) read the file content

   public async Task RestoreFile(IStorageFile file)
{
//read incoming file
using (var fs = await file.OpenStreamForReadAsync())
{
try
{
var vault = ConvertStreamToObject(new StreamReader(fs, System.Text.Encoding.UTF8, true));

var lst = vault.Entries.OrderBy(x => x.Title).ToList();

//save to disk
await SaveDataAsync(lst);
}
catch (Exception ex)
{
TelemetryService.LogException(ex);
}
}
}