Try our conversational search powered by Generative AI!

How to configure EpiServer 7 CMS, Dynamic Data Store in Console application

Vote:
 

I want to create EpiServer 7 CMS page programaticaly, I find link
"http://world.episerver.com/Documentation/Items/Developers-Guide/EPiServer-CMS/7/Content/Pages-and-Blocks/How-To/Creating-a-Page-Programmatically/" but unable to crate by console application.
basically I want to perform CURD operation for product,page,account and category etc. from console application.


#77094
Nov 08, 2013 8:08
Vote:
 

What error are you getting?

Frederik

#77095
Nov 08, 2013 8:51
Vote:
 

Hi Frederik,

Please find a the details of the code at a snapshot below and please help me figuring out the issue

In my app config I entered

  <episerver.dataStore>
    <dataStore defaultProvider="EPiServerSQLServerDataStoreProvider">
      <providers>
        <add name="EPiServerSQLServerDataStoreProvider" description="SQL Server implementation of Data Store" type="EPiServer.Data.Dynamic.Providers.SqlServerDataStoreProvider, EPiServer.Data" connectionStringName="EPiServerDB"/>
      </providers>
      <cache defaultProvider="nullCacheProvider">
        <providers>
          <add name="httpCacheProvider" description="Http Cache implementation for DataStore" type="EPiServer.Data.Cache.HttpRuntimeCacheProvider,EPiServer.Data.Cache" />
          <add name="nullCacheProvider" description="Null Cache implementation for DataStore" type="EPiServer.Data.Cache.NullCacheProvider,EPiServer.Data" />
        </providers>
      </cache>
    </dataStore>
  </episerver.dataStore>


And the initialization code is:

    var container = new StructureMap.Container();
    var factory = new SqlDatabaseFactory();
    container.Configure(ce => ce.For<IDatabaseHandler>().Use(factory.CreateDefaultHandler));
    ServiceLocator.SetLocator(new StructureMapServiceLocator(container));
    DataInitialization.InitializeFromCode(container, factory, null);
    var store = typeof(SampleModel).GetStore();

The exception I am getting is:

exception Message:
Activation error occurred while trying to get instance of type IDatabaseHandler, key ""

InnerException :

{"StructureMap Exception Code:  207\nInternal exception while creating Instance 'c83caeb3-0d4f-4775-853b-8b7ae906265a' of PluginType EPiServer.Data.IDatabaseHandler, EPiServer.Data, Version=7.0.859.24, Culture=neutral, PublicKeyToken=8fe83dea738b45b7.  Check the inner exception for more details."}

StackTrace:

   at StructureMap.Pipeline.LambdaInstance`1.InstanceBuild(Type pluginType, BuildSession session)
   at StructureMap.Pipeline.Instance.createRawObject(Type pluginType, BuildSession session)
   at StructureMap.Pipeline.Instance.Build(Type pluginType, BuildSession session)
   at StructureMap.Pipeline.ObjectBuilder.ConstructNew(Type pluginType, Instance instance, BuildSession session)
   at StructureMap.Pipeline.ObjectBuilder.Resolve(Type pluginType, Instance instance, BuildSession session)
   at StructureMap.BuildSession.CreateInstance(Type pluginType, Instance instance)
   at StructureMap.BuildSession.<>c__DisplayClass3.<.ctor>b__1()
   at StructureMap.BuildSession.CreateInstance(Type pluginType)
   at StructureMap.Container.GetInstance(Type pluginType)
   at EPiServer.ServiceLocation.StructureMapServiceLocator.DoGetInstance(Type serviceType, String key)
   at EPiServer.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
   at EPiServer.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
   at EPiServer.ServiceLocation.ServiceLocatorImplBase.GetInstance[TService]()
   at EPiServer.Data.Providers.SqlDatabaseFactory.get_CurrentHandler()
   at EPiServer.Data.DataInitialization.InitializeFromCode(IContainer container, IDatabaseFactory dbHandlerFactory, CacheProvider cacheProvider)

Thanks,
Chirag

#77097
Nov 08, 2013 10:07
Vote:
 

Had the same problem,

fixed it by using:

<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="StructureMap" publicKeyToken="e60ad81abae3c223" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.4.0" newVersion="2.6.4.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>

#80447
Jan 23, 2014 8:43
Vote:
 

Chirag, sorry for delayed answer. We just came across the same issue. Check exception's inner exception. If structuremap is complaining about "Entry point is not found", double check your app.config file. You may missing redirect to proper structuremap assembly used in the project (as Gatis mentioned above):

<dependentAssembly>
<assemblyIdentity name="StructureMap" publicKeyToken="e60ad81abae3c223" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.4.0" newVersion="2.6.4.0" />
</dependentAssembly>

    

#80448
Jan 23, 2014 8:44
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.