Quantcast
Channel: Developer to developer
Viewing all articles
Browse latest Browse all 9076

No Default Instance defined for PluginFamily EPiServer.Data.IDatabaseHandler

$
0
0

I'm working on upgrading an Episerver solution from 6 R2. I'm on version 8.11 at the moment.

Some of the old code uses Dynamic Data Store. When I run the code that reads content from the DDS, I get the following error:

StructureMap Exception Code: 202 No Default Instance defined for PluginFamily EPiServer.Data.IDatabaseHandler, EPiServer.Data, Version=8.11.0.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7

I'm trying to figure out how to configure this in StructureMap:

I have tried this code:

public static void ConfigureStructureMap()
{
    ObjectFactory.Initialize(x =>
    {
        // Lots of x.For<Interface>().Use<Implementation>();
        x.For<IDatabaseHandler>().Use(new SqlDatabaseFactory().CreateDefaultHandler());
    });
}

Then I get rid of the above error message, but I get other errors instead when I'm trying to write to the DDS:

Call from wrong thread - the DatabaseHandler classes are not thread safe!

From Episerver's documentation, it seems I should not use SqlDatabaseFactory this way: "This class supports the EPiServer infrastructure and is not intended to be used directly from your code." I guess it is intended for mocking and creating tests.

What can cause Episerver to not initialize its implementation of IDatabaseHandler properly?

Is there a way for me to initialize it myself (like I'm trying to with SqlDatabaseFactory) where it will work?

I'm thankful for any help I can get.


Viewing all articles
Browse latest Browse all 9076

Trending Articles