Dependency Injection in SharePoint 2013

If someone would ask me a while ago when I use property injection, I would definitely say NEVER. But then ASP.NET WebForms/SharePoint happened… I usually prefer using constructor injection, but in this case, this doesn’t seem possible.

Constructor injection vs property injection

Like the words indicated, the injection in constructor injection occurs within the constructor of the class and with property injection, the injected object is inserted into the property

Constructor injection:

Property injection:

(more…)

Using EntityFramework in SharePoint

When adding the EntityFramework package from NuGet into a SharePoint project with the command:

PM> Install-Package EntityFramework

We got to make sure some things are configured into SharePoint. You’ll notice that adding the package creates a new App.config file. The XML in this file should be added to the web.config file from SharePoint. But to make sure we safely edit the config, we create an eventreceiver and add the necessary nodes there.

(more…)

Signing packages

When adding a new NuGet package to the Package folder in a SharePoint project, we often get this error, since not all packages are strongly named:

Error occurred in deployment step ‘Add Solution’: This solution contains one or more assemblies targeted for the global assembly cache. You should use a strong name for any assembly that will be in the global assembly cache.

(more…)

IoC Container in SharePoint 2013 Service

Since quite some time I started learning about Dependency Injection and IoC Containers. When I couldn’t find any solutions for SharePoint, I first thought it was impossible to do, especially constructor injection. But when I had a closer look, I started to imagine a solution for this particular problem and after a while I managed to get it working. So with no further ado, I present you my fix:

(more…)