WCF debugging using Service Trace Viewer Tool (SvcTraceViewer.exe)

Calling a WCF service caused following exception:

An existing connection was forcibly closed by the remote host

Using the Service Trace Viewer Tool can help diagnose the root cause of the exception .( see the msdn documentation )

On my Windows 10 PC the tool is located here:

C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools>

If the WCF service is hosted by IIS add the following to web.config:

  <system.diagnostics>
    <trace autoflush="true" />
    <sources>
      <source name="System.ServiceModel"
              switchValue="Information, ActivityTracing"
              propagateActivity="true">
        <listeners>
          <add name="sdt"
              type="System.Diagnostics.XmlWriterTraceListener"
              initializeData= "c:\temp\wcflogs\cdui.log" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>

Invoke the service then open the log file created (c:\temp\wcflogs\cdui.log in this example) using the tool. Exceptions are highlighted in red and give the call stack.

Couchbase – Could not bootstrap

Couchbase server installed on Windows. Trying to connect gives the not very helpful exception “Could not bootstrap – check inner exception for details”. The inner exception is not much more helpful “One or more errors occurred” and in the inner-inner exception we finally get “A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond”

Write a console app like this:

using System;
using Couchbase;
using Couchbase.Core;
using Couchbase.Configuration.Client;

namespace ConsoleApplication4
{
    class Program
    {

        static void Main(string[] args)
        {
            Cluster cluster;
            IBucket bucket;

            var hosts = "http://mycouchbaseserver.staging";
            var bucketName = "MyTestBucket";

            try
            {
                if (!string.IsNullOrWhiteSpace(hosts))
                {
                    var password = "myPassword";
                    var servers = hosts.Split(',')
                        .Select(h => new Uri(h))
                        .ToList();

                    cluster = new Cluster(new ClientConfiguration
                    {
                        Servers = servers
                    });

                    bucket = cluster.OpenBucket(bucketName, password);

                    Console.WriteLine("done");
                    Console.ReadKey();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("ERROR");
                Console.WriteLine("Exception = " + ex.Message);
                if (ex.InnerException != null)
                {
                    Console.WriteLine("Inner Exception = " + ex.InnerException.Message);

                }
                Console.ReadKey();
            }
        }
    }
}

If the console app works locally, but not on a remote server then it’s probably windows firewall settings.

Open inbound TCP ports 8091, 8092, 11210.

SQL Server – Fixing user after restore database to another server

Restore a database from backup file to a new server using TSQL:

restore database [Umbraco]
from disk='e:\ftp\Umbraco_20150916.BAK'
with move 'Umbraco' to 'E:\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\Umbraco.mdf',
move 'Umbraco_log' to 'E:\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\Umbraco_log.ldf'

To fix the user (in this case user1):

EXEC sp_change_users_login 'UPDATE_ONE','user1','user1'

JQuery plugin to get all cells in a table column

Found this useful plugin …

mindplay-dk/jquery.column.js

Here is the code

/**
 * Find all cells (td/th) in the column of the current cell.
 * (excluding rows with cells that span multiple columns.)
 */

(function($) {

  $.fn.column = function() {
    return $(this)
      .filter('th, td')
      .filter(':not([colspan])')
      .closest('table')
      .find('tr')
      .filter(':not(:has([colspan]))')
      .children(':nth-child(' + ($(this).index()+1) + ')');
  }

})(jQuery);

Usage: shown here to change style of all glyphicons in hovered table column

            $("table").delegate('th','mouseover mouseleave', function(e) {
                if (e.type == 'mouseover') {
                    $("colgroup").eq($(this).index()).addClass("hover");

                    $(this).column().find('span.glyphicon').addClass("fire");
                }
                else {
                    $("colgroup").eq($(this).index()).removeClass("hover");

                    $(this).column().find('span.glyphicon').removeClass("fire");
 
                }
            });

Visual Studio Code / GitHub Desktop

Trying to use github integration from VS Code alongside GitHub Desktop.

Kept getting authorization error like this:

remote: Anonymous access to myGitHubUserName/MyGitHubRepo.git denied.
fatal: Authentication failed for ‘https://github.com/myGitHubUserName/MyGitHubRepo.git/&#8217;

Installed git from http://git-scm.com/download

Ran Git Bash and then following commands in source code folder:

$ git config –global credential.helper wincred
$ git push -u origin master

 

… Update 24th Nov 2015 ….

It appears there is an issue with VS Code and github for Windows:

https://github.com/Microsoft/vscode/issues/490

 

Lost all my TFS workspaces / Visual Studio thinks I’m a different user

This morning I booted my PC, started Visual Studio only to find all my TFS workspaces were missing.

I opened a visual studio command prompt and ran:

tf workspaces

this confirmed that all my workspaces were still on my pc.

I mapped a project to the default workspace, checked out a file – it showed the file checked out to a different user!

After a bit of googling it turns out that Windows had cached the “wrong” credentials. To resolve this open Control Panel (Windows 10) and go to “manage your credentials” then “Windows credentials” and click on the entry for the TFS server then click the “remove” link.

This issue occurred because I had logged into a website hosted on “devops” server as another user. Our TFS is also hosted on the “devops” server.

Removed the entry from the credentials cache then restarted Visual Studio. My workspaces are now found 🙂