Browsed by
Category: Programming

How to create a NuGet package

How to create a NuGet package

A few days ago I looked into setting up our private NuGet server as a way for us to share code, instead of using git sub modules for example. Turns out setting up the server is as simple as starting an empty web project in visual studio and adding the NuGet server package: http://nugetserver.net/. On a side note, if you are already using team city, you can use this as a NuGet repository, just select create artifact with the package…

Read More Read More

Unit Testing with NUnit

Unit Testing with NUnit

A very short intro and comparison between the MSTest framework and the very popular NUnit framework. For a more complete list of differences between the frameworks, see: https://xunit.github.io/docs/comparisons.html. Getting started Add a new project to your visual studio solution. I found 3 different ways to get started: Add a unit test (MSTest) project to your solution, remove the references to MSTest and add the nuget package NUnit to your project. Start with an class library and add the nuget package:…

Read More Read More

CiviCRM: Missing indexes after upgrade

CiviCRM: Missing indexes after upgrade

After upgrading our CiviCRM we got a notification about missing indexes. It turns out (according to stack overflow) it’s pretty easy to solve if you have drush installed. List all missing indexes drush ev ‘civicrm_initialize();print_r(CRM_Core_BAO_SchemaHandler::getMissingIndices())’ (re)Create all drush cvapi System.updateindexes

PuTTY known_hosts

PuTTY known_hosts

Where does putty store it’s known_hosts? I asked myself this question today after battling a git extensions bug where you can’t type in the console window and as a result can’t add the host to the known hosts. The answer: HKEY_CURRENT_USER\SoftWare\SimonTatham\PuTTY\SshHostKeys To manually add hosts, use plink. plink.exe yourservername Hope it helps you.

Execute large SQL script on MS SQL server

Execute large SQL script on MS SQL server

Having trouble executing a large SQL script using the SQL server management studio? Use the command line tool sqlcmd sqlcmd -S server\instance -i script_file.sql This should work, unless you have errors in your script of course 😉 Don’t forget to start your script with a correct use statement. use databaseNameHere;

.NET Web API OData and Entity Framework Database First: No Key defined

.NET Web API OData and Entity Framework Database First: No Key defined

When using EF database first, I came across an error: No Key defined… Turns out the generated classes are not decorated with the [Key] attribute. You can manually add them but once you generate your model(s) again, it’s all gone. There are workarounds floating across the internet to edit the T4 template(s) that generate these models, but every developer has to do that, plus I didn’t want to fiddle around with those files. Another way is to map your key(s)…

Read More Read More

.NET Web API and OData: Cannot serialize a null ‘feed’

.NET Web API and OData: Cannot serialize a null ‘feed’

Recently I came across an error when working with oData and web API. Cannot serialize a null ‘feed’. System.Runtime.Serialization.SerializationException I couldn’t really find a solution online, but it turns out i just forgot to decorate my method parameter with [FromODataUri]. [EnableQuery] public IQueryable Get([FromODataUri] ODataQueryOptions queryOptions) { … } Now you can use $expand and $select in your URL without issues.

Drupal: How to turn off automatic enclosing <p> tags in CKEditor

Drupal: How to turn off automatic enclosing <p> tags in CKEditor

Using my previous post on how to turn of the automatic paragraph tags in CKEditor, I knew how to shut this feature off but I didn’t know where. vim sites/all/libraries/ckeditor/config.js Then add this to the config section: CKEDITOR.editorConfig = function( config ) { // Define changes to default configuration here. For example: // config.language = ‘fr’; // config.uiColor = ‘#AADC6E’; CKEDITOR.config.enterMode = CKEDITOR.ENTER_BR; }; Save and refresh the page.

C#.NET: Does object have method or property?

C#.NET: Does object have method or property?

I wanted to see if I could determine if an object had a certain property. I came across this post, that explained how to do this using reflection in .NET. Here is what the little extension class looks like: public static class Extensions { public static bool HasMethod(this object objectToCheck, string methodName) { var type = objectToCheck.GetType(); return (type.GetMethod(methodName) != null); } public static bool HasProperty(this object objectToCheck, string propertyName) { var type = objectToCheck.GetType(); return (type.GetProperty(propertyName) != null); }…

Read More Read More

Keyset does not exist error in .NET application

Keyset does not exist error in .NET application

When using WCF to communicate with a web service that required a client certificate, I couldn’t get the solution to run unless I started Visual Studio as an administrator. The error that I got was : System.Security.Cryptography.CryptographicException Keyset does not exist I knew full well the private key did exist (you can see this in MMC > Certificates). So it had to be a security related issue, seeing that when I run it as admin I have no issues. After…

Read More Read More