The correct way to implement StructureMap in .NET Core WebApi when having multiple projects

StructureMap is an IoC/DI container for .Net which has been a long time around. I’ve been using it for these past few years, and after all this time, I found out the correct way to implement it.

This is how I used it before and I’m sure the majority of you are currently using the same methods. In the Registry, I would register each interface and it’s inherited class by calling a “config.for” for each service as follows:

    config.For(typeof(ITestService)).Add(typeof(TestService));
    config.For(typeof(IUserService)).Add(typeof(UserService));
    config.For(typeof(ITenantService)).Add(typeof(TenantService));
    config.For(typeof(IProjectService)).Add(typeof(ProjectService));

And whenever new interfaces and services are added, they need to be registered using a new “config.for” line.

That was the old way, of how I did things. This is the new way. Continue reading

Solution | Unable to write output file ‘…pdb’; unspecified error

Visual Studio 2005 / 2008

During this weekend, I started having a problem when building a solution in Visual Studio. It would load the following error:

Unable to write to output file Solution_Name.pdb

This Visual Studio solution has 8 projects, and a lot of files and folders. I tried several solutions that I found on the net, which worked for others, but none worked for my case including:

  • Delete the .pdb file from the solution – Didn’t Work
  • Delete the Debug folder – Still Didn’t work
  • Delete the whole obj Folder – Nothing Continue reading