Skip to content $10 free credit

2015 February 26

I will be using Digitalocean for my next major project, and I just wanted to pass along this chance to get  $10 in credit.  Simply follow the link below and sign up for an account and receive $10 in credit.

 $10 DigitalOcean Credit Click Here

It seems like a pretty good hosting company from what I’ve seen so far.

How to Clone a GIT Repo from Team Foundation Services using Visual Studio

2015 January 27

If you are using Team Foundation Services (now called Visual Studio Online I believe), to host GIT repos, here is a step by step guide on how to clone the repo by using the clone URL, which can be difficult to find on the TFS site.

  1. Open Team Explorer (View → Team Explorer)
  2. Click the Connection button at the top of Team Explorer.  And then click the “Clone” Link
    Visual Studio 2013
  3. In a we browser Log into your TFS site to get the URL to clone the GIT Repo.
  4. Find the project you want to clone click on the link for it (you might have to “Browse” for your project if you haven’t used it recently)
  5. Click on “Code” in the menu, Then Click on the project, and then over on the right side of the screen click on the Clone button.  You can see this in the image below:
  6. Copy this URL and Return to Visual Studio.
  7. Paste the URL into the top box and then select a path for your Repo to be held locally as seen in this image:
  8. Then click Clone.
  9. Now you should have the files downloaded to your local system and you should be able to open the project solution files at this point using Visual Studio. However…
  10. When you try to open the project it might be blank and you might see this error in the Output window.  Object reference not set to an instance of an object.
  11. If you see this error, do the following:
    1. Go to Team Explorer (View → Team Explorer).  Right click on the solution in the solution section and click “Open” .
    2. Then you can open the Solution Explorer (View → Solution Explorer) and you should see the files.

Uploading a file to Amazon AWS S3 with .NET C# in Visual Studio

2014 October 3
by mark

This is just a very basic example of how to upload a file to Amazon AWS S3 using .NET C#.  It’s so basic that it creates the contents of the file from a string.  I just used this to make sure that my keys and bucket were all set right.

  • First you need to use NuGet to add the AWS SDK for .NET

Then you can use the following code and replace the RegionEndpoint with the location you are using (although, it might not matter because S3 says that you don’t have to worry about regions):


using System;
using Amazon;
using Amazon.S3;
using Amazon.S3.Model;

namespace UploadtoS3
    class Program
        static void Main(string[] args)
            const string AWS_ACCESS_KEY = "ASSDFSDFSEFER123ASDFCV234";
            const string AWS_SECRET_KEY = "asdf234SFDh+24sadASDFasdf324SDsdf=";

            AmazonS3Client client = new AmazonS3Client(AWS_ACCESS_KEY, AWS_SECRET_KEY,RegionEndpoint.USEast1 );

            PutObjectRequest request = new PutObjectRequest();
            request.BucketName = "MyBucketName";
            request.Key = "MyFileName.txt";;
            request.ContentBody = "This is the contents of the File.";

How to publish SQL Server Compact DB to another computer or server

2014 September 23

You may have seen an error like:

Unable to load the native components of SQL Server Compact corresponding to the ADO.NET provider of version 8876. Install the correct version of SQL Server Compact. Refer to KB article 974247 for more details.

Or you might be asking what DLL’s are necessary for SQL Server Compact database to run on a server?  Or, how do you publish an application to a server which uses SQL Server Compact DB?

You will need to copy the following file and entire directory to the location where your .exe is running on your server.  This file and folder are most likely  in the directory C:\Program Files(x86)\Microsoft SQL Server Compact Edition\V4.0\Private

  • System.Data.SqlServerCe.dll
  • The entire amd64 folder

I’m not sure what is used from the amd64 folder, but as soon as I copied this over my application started to work.  You could also get your System.Data.SqlServerCe.dll file by clicking on it in Visual Studio under the References folder and then in the properties tab setting “Copy Local” to True and then when you build your app that file will be in your release folder.

How to add SQL Server Compact Database (.sdf) to Visual Studio 2013 Project

2014 September 18

SQL Compact has more or less been removed from Visual Studio 2013, however there are still ways to use SQL Server Compact DB in your project.

Install SQL Server Compact/SQLite Toolbox

Add a SQL Compact DB to a Project

  • Open Visual Studio
  • Create a new project if you don’t already have one
  • In Visual Studio from the Menu Select Tools–>SQL Server Compact/SQLite Toolbox and this will bring up a new window.  The window might tell you to restart VS again, and if so you’ll want to do that.
  • Next right click on Data Connections and select Add SQL Server Compact 4.0 Connection and then fill in the fields
    • For the Filename field click the create button and choose the root of your project
    • For Size and Password you can set these to whatever you want, a password is not required
    • DON’T Forget to copy the connection string which will be helpful in connecting to the DB
    • compactdb1
    • Click OK when you are done

Create a Table in the Compact Database

  • Right click on the myDB.sdf connection that you just created and select Build Table (beta)…
  • Create a Customers table like below
  • Click on Script when you are done.
  • Then click the Execute button to create a table
  • Expand myDB.sdf and then expand the Tables folder and then right click on the Customers table and select Edit top 200 rows
  • Add some records to the DB
  • Return to your Solution and add the .SDF file to your project.  To do so you will need to click the button to “Show All Files”
  • Then right click on myDB.df and select “Include in Project”

Add the connection String

  • In my example, I have a console application so I’m adding the connection string to the App.config file:
<?xml version="1.0" encoding="utf-8"?>
    <add name="SyncDB" providerName="System.Data.SqlServerCe.4.0" connectionString="Data Source=|DataDirectory|myDB.sdf;Max Database Size=256;Password=mypassword1" />

        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>


 Query the Compact DB

  • First Right click on References and select Add Reference…
  • Add the System.Data.SqlServerCe reference to your project (NOTE: If you don’t see this in your list, Click Browse, and then go to C:\Program Files(x86)\Microsoft SQL Server Compact Edition\V4.0\Private and then select the dll file there).
  • Then add the using statement using System.Data.SqlServerCe
  • Then you can query the DB by doing the following:
    using (SqlCeConnection cn = new SqlCeConnection(ConfigurationManager.ConnectionStrings["myDB"].ToString()))
        SqlCeCommand cmd = new SqlCeCommand("SELECT * FROM Customers", cn);
        SqlCeDataReader reader1 = cmd.ExecuteReader();
        while (reader1.Read())
            Console.WriteLine(reader1[0] + " | " + reader1[1] + " | " + reader1[2] + " | " + reader1[3] + " | " + reader1[4]);

catch (Exception ex)
      Console.WriteLine("Error Reading from myDB: " + ex.Message);

The “EnsureBindingRedirects” task failed unexpectedly. Referenced Assembly does not exist.

2014 August 27

The “EnsureBindingRedirects” task failed unexpectedly. Referenced Assembly does not exist.

After downloading a project from visual studio online to my local machine I received the following error when trying to build, also, all my references in the solution explorer had a little yellow error icon.:
Error 1 The “EnsureBindingRedirects” task failed unexpectedly.
System.IO.FileNotFoundException: Referenced assembly does not exist.
File name: ‘C:\Users\admin\Documents\Visual Studio 2013\Projects\MyApplication\MyApplication\MyApplication\packages\Microsoft.Net.Http.2.1.10\lib\net45\System.Net.Http.Extensions.dll’
at Roxel.BuildTasks.EnsureBindingRedirects.MergeBindingRedirectsForReferences()
at Roxel.BuildTasks.EnsureBindingRedirects.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext() MyApplication

How to Fix

In the Package manager console run the following command to re-install the packages (make sure you only have the project open that is having the problem because I think it might reinstall all packages on all open projects):

PM> update-package -reinstall

How to Fix Windows Backup of Hyper-V Error: The Writer Experienced a NON-TRANSIENT error. If The Backup Process Is Retried, The Error Is Likely To Reoccur

2014 August 20


I tried to run a backup of my Hyper-V instances using Windows Server Backup on Windows 2012 R2 and received the following error:
Error: The Writer Experienced a NON-TRANSIENT error. If The Backup Process Is Retried, The Error Is Likely To Reoccur


The way I fixed this was to add Authenticated Users to have access (Probably just Read access, although I’ve only tried it with Full access) to the folder where you store your VM’s.  For me I am storing my VMs in e:\VMs

After making the change the backup worked fine.

How to add SSL Cert to Amazon AWS Load Balancer with optional Backend Authorization

2014 August 8
  1. Create a CSR (Certificate Request) on your server, in our case we are using IIS.  You can find instructions on how to generate a CSR here for most web servers and platforms.
  2. Using your CSR, request the SSL certificate from your SSL provider such as Digicert, godaddy, or other SSL provider.
  3. Once they process your request and give you the certificate, you can finish the CSR request on your server and complete the install of the certificate on your server.
  4. After you install the cert, you need to export the certificate and the private key in PEM format.  I did this on windows, so the following steps are for windows.  On Linux it will be a little different.
    1. On the server open a command line and run: MMC
    2. Go to File–>Add Remove Snap
    3. Select Certificates
    4. Choose Computer Account and click next
    5. Select Local Computer and click Finish
    6. Click OK
    7. In the left hand column expand Certificates–>Personal–>Certificates
    8. Right click your certificate and select All Tasks –> Export
    9. Click Next and then select “Yes, export the private key”
    10. Leave the default Personal Information Exchange – PKCS #12 (.PFX) selected and the checkbox checked for Include all certificates in the certification path if possible
    11. Click Next and then give it a password and click next.  The password can be anything you want.
    12. Choose the file to output to.
    13. Download and install OpenSSL 64 Bit for windows: Win64, if you don’t have OpenSSL already
    14. Run the following commands from the bin folder inside the location where you installed OpenSSL
      1. openssl pkcs12 -in c:\yourexportedfilefromstep7.pfx -nocerts -out key.pem
      2. Enter your password you set in #11
      3. openssl rsa -in key.pem -out server.key
      4. Enter your password
      5. These two steps convert your private key from pfx to pem format and then remove the password from the file.  It saves the private key without password as server.key file.  So you’ll want to be careful about this file and the key.pem file as well.
  5. Now return to AWS and create your elastic load balancer.  If you want to have back end authorization (i.e. SSL between your server and the load balancer) you need to add it when you create the load balancer, otherwise you will need to use AWS command line tools to add it later since there is currently no way to add backend authorization to an existing load balancer through the web interface.
  6. Add the HTTPS listener to your elastic load balancer, make sure that HTTPS is set for the Instance Protocol as well if you want to do backend-authorization .  If not you can just leave it port 80 on the Instance Protocol.aws1
  7. Click on Change SSL Certificate ( or Upload a new SSL Certificate)
  8. Give your certificate a name (which can be anything without spaces)
  9. Copy the private key text which will be in the server.key file that you created above
  10. Copy the Certificate that you purchased (which should be X509 Certificate Only, Base64 encoded) into the Public Key Certificate Field.  Optionally, if you have intermediate keys, you will want to insert those into the Optional Certificate Chain Field in reverse order.  (NOTE: if it gives you an error that the certificates are not in the right order then you will want to reverse the order of your intermediate keys)
  11. Use the Predefined Security Policy for the Cipher unless you have a reason not to.aws2
  12. If you are doing backend authentication, make sure you select Enable backend authentication on the Backend Certificate page
  13. For Certificate Name type in any name you want for the key except don’t use spaces in your name
  14. For the Certificate Body, take the certificate that you purchased and installed on your server and put it in this field, HOWEVER, I’ve found that I need to remove any line breaks in the certificate or else it won’t work.
  15. Finish out the load balancer creation with healthchecks, security groups, and your server and you should be good to go.  Don’t forget to have 443 traffic open in your security group from the server to the load balancer as well as from the load balancer to the internet.

How to add libraries (dll files) to a custom DNN module

2014 August 8

DNNCorp_logo_lrgIf you are building a DNN module most likely you’ll be using Christoc’s Module Template and if you need to add an additional library you need to make a few changes to the following files.

In the projectname.dnn file add the following component tag for each dll that you have, replacing the with your library name:

<component type="Assembly">

In the ModulePackage.Targets file add the following line 2 times, once for the install section and once for the source zip files section. Look for the lines that have $(MSBuildDNNBinPath)\$(AssemblyName).dll in them and put it under these, replace the dll name with your dll’s name:

<Copy SourceFiles="$(MSBuildDnnBinPath)\LinqToTwitterPcl.dll" DestinationFolder="$(MSBuildProjectDirectory)\Package\bin"/>

If you install a nuget package that makes additions to the web.config file you will need to add those changes to the web.config file of the web server running DNN. I don’t think that making these changes to the web.config for the module works, I think it has to be on the server. In the example of using linq2twitter.dll we also needed to add the following line to the web.config file:

    <assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
    <bindingRedirect oldVersion="" newVersion="" />

How to copy Microsoft SQL Server tables, including data, from one database to another

2014 August 7

upload_databaseTo copy  database tables, including data, from one database to another  using SQL Managment Studio is not to difficult, just do the following.

  • Right click on the database with the tables you want to copy and select Tasks–>Generate Scripts
  • Click Next
  • You can choose to script the everything in the database or just certain tables, or users or other stored procedures and such.  Don’t forget the stored procedures if you have any.
  • Make you choices and choose next.
  • Click the Advanced Button
  • If you want it to script the data and schema, then change “Types of data to script” to “Schema and data”
  • Look through the options and make sure the other options fit your needs.  Some things that I find helpful to make sure that they are checked include:
    • Generate Script for Dependent Objects (if you don’t know what dependent objects might exist)
    • Script Indexes
    • Script Full-Text Indexes
  • Click ok
  • Make sure the output file name is where you want to save it.
  • Click Next a few times and then Finish to output the schema and data to the file
  • On the destination database server create a new query.  Copy the text from the file you just created into the query.  MAKE SURE that you change the <strong> Use [DatabaseName]</strong> line at the top of the query to the name of the database that you are copying to.
  • Run the Query.  You should now have all the tables and data in the new server.