Reputation: 16532
I am using ASP.NET core and I'm trying to make use of structuremap for my IoC, but I seem to be having some issues. When I write a unit test that inits structuremap directly, everything works fine. When I print the configuration out to file, I can see that my setup is indeed registering everything correctly.
However, the populate seems to be giving me trouble.
I am trying to use StructureMap.Microsoft.DependencyInjection but I get an error when I build:
The dependency structuremap >= 4.4.0 could not be resolved.
I have StructureMap 4.4.1 installed in my project, including the project I installed the StructureMap.Microsoft.DependencyInjection library into (my Web API project).
So, I then took the files out of the project on github and loaded them into my solution, and removed the nuget package, but for some reason it is not working.
Here is a plunker with the relevant files
Ideally, I'd rather use the nuget package to do this, but I've never encountered a dependency issue when I have the actual dependency already installed.
EDIT: A few more details
When I write the results of container.WhatDoIHave()
to a file, my classes are all shown correctly t0 be part of structuremap, however when I run container.AssertConfigurationIsValid();
is when I am getting errors about things correctly defined as reported by WhatDoIHave()
Here is what my configure method looks like
public IServiceProvider ConfigureIoC(IServiceCollection services)
{
var container = new Container();
container.Configure(config =>
{
// scan the webapi to register all the controllers
config.Scan(scan =>
{
scan.TheCallingAssembly();
scan.WithDefaultConventions();
});
//this is an IoC configuration in another library that
// ties together a bunch of class libraries so they
// don't all have to be in my web project
IoC.BootStrapper.Configure(config, "MembershipReboot");
});
System.IO.File.WriteAllText(@"C:\users\{me}\documents\structuremapTest.txt", container.WhatDoIHave());
container.AssertConfigurationIsValid();
//Populate the container using the service collection
container.Populate(services);
return container.GetInstance<IServiceProvider>();
}
Upvotes: 1
Views: 2476
Reputation: 8508
See this issue on the StructureMap.Microsoft.DependencyInjection issue tracker:
The dependency structuremap >= 4.3.0 could not be resolved https://github.com/structuremap/StructureMap.Microsoft.DependencyInjection/issues/17
Upvotes: 0
Reputation: 1587
Rename the "StructureMap" package to "structuremap", seems like some weird issue with NuGet casing.
Cheers :)
Upvotes: 3