Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • lj 81 posts 425 karma points
    Sep 05, 2013 @ 18:00
    lj
    0

    using ucommerce from console app

    Trying to set up ucommerce to work with a standalone windows console application for a product import. I followed the blog http://www.publicvoid.dk/UsingTheUCommerce3APIInAWindowsApplication.aspx for setting up ucommerce to work with a console application. At the end of the article I downloaded the code. I then added a connection string which I know works from an umbraco intallation with ucommerce. but when I run i get the following error.  

     

      Castle.MicroKernel.ComponentActivator.ComponentActivatorException: ComponentA
    vator: could not instantiate UCommerce.EntitiesV2.Repository`1[[UCommerce.Ent
    esV2.PurchaseOrder, UCommerce, Version=3.5.0.13098, Culture=neutral, PublicKe
    ken=null]] ---> System.Reflection.TargetInvocationException: Exception has be
    thrown by the target of an invocation. ---> FluentNHibernate.Cfg.FluentConfig
    tionException: An invalid or incomplete configuration was used while creating
    SessionFactory. Check PotentialReasons collection, and InnerException for mor
    etail.

     ---> System.Data.SqlClient.SqlException: Login failed for user 'umbraco'.
       at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException except
    , Boolean breakConnection, Action`1 wrapCloseInAction)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserState
    ect stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
       at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlComm
     cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandle
    TdsParserStateObject stateObj, Boolean& dataReady)
       at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand
    dHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler,
    ParserStateObject stateObj)
       at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean en
    tOK)
       at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerIn
    serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignor
    iOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
       at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerIn
    serverInfo, String newPassword, SecureString newSecurePassword, Boolean redir
    edUserInstance, SqlConnectionString connectionOptions, SqlCredential credenti
     TimeoutTimer timeout)
       at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutT
    r timeout, SqlConnectionString connectionOptions, SqlCredential credential, S
    ng newPassword, SecureString newSecurePassword, Boolean redirectedUserInstanc
       at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolId
    ity identity, SqlConnectionString connectionOptions, SqlCredential credential
    bject providerInfo, String newPassword, SecureString newSecurePassword, Boole
    redirectedUserInstance, SqlConnectionString userConnectionOptions)
       at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectio
    tions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbC
    ectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptio

       at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbC
    ectionPool pool, DbConnectionOptions options, DbConnectionPoolKey poolKey, Db
    nectionOptions userOptions)
       at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnectionOpti
     userOptions)
       at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnectio
    tions userOptions)
       at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
    ningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolea
    nlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal&
    nnection)
       at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
    ningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, Db
    nectionInternal& connection)
       at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnect
     owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOpti
    , DbConnectionInternal& connection)
       at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnect
     outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource
    retry, DbConnectionOptions userOptions)
       at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retr
       at System.Data.SqlClient.SqlConnection.Open()
       at NHibernate.Connection.DriverConnectionProvider.GetConnection()
       at NHibernate.Tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.Prep
    ()
       at NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.GetReservedWords(Dialect
    lect, IConnectionHelper connectionHelper)
       at NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.Update(ISessionFactory se
    onFactory)
       at NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping ma
    ng, Settings settings, EventListeners listeners)
       at NHibernate.Cfg.Configuration.BuildSessionFactory()
       at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
       --- End of inner exception stack trace ---
       at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
       at UCommerce.EntitiesV2.SessionProvider.CreateSessionFactory(Boolean enabl
    che, String cacheProvider)
       at UCommerce.EntitiesV2.SessionProvider.GetSession()
       at UCommerce.EntitiesV2.Repository`1..ctor(ISessionProvider sessionProvide
       --- End of inner exception stack trace ---
       at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] argumen
     Signature sig, Boolean constructor)
       at System.Reflection.RuntimeConstructorInfo.Invoke(Object obj, BindingFlag
    nvokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
       at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.FastCre
    Instance(Type implType, Object[] arguments, Type[] signature)
       at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateI
    ance(CreationContext context, Object[] arguments, Type[] signature)
       --- End of inner exception stack trace ---
       at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateI
    ance(CreationContext context, Object[] arguments, Type[] signature)
       at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instant
    e(CreationContext context)
       at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Interna
    eate(CreationContext context)
       at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create
    eationContext context)
       at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Resolve(CreationC
    ext context)
       at Castle.MicroKernel.Lifestyle.PerThreadLifestyleManager.Resolve(Creation
    text context)
       at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext
    text, Boolean requiresDecommission, Boolean instanceRequired)
       at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext con
    t, Boolean instanceRequired)
       at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext con
    t)
       at Castle.MicroKernel.Handlers.DefaultGenericHandler.ResolveCore(CreationC
    ext context, Boolean requiresDecommission, Boolean instanceRequired)
       at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext con
    t, Boolean instanceRequired)
       at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext con
    t)
       at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Typ
    ervice, IDictionary additionalArguments)
       at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Typ
    ervice)
       at Castle.MicroKernel.DefaultKernel.Resolve(Type service)
       at Castle.Windsor.WindsorContainer.Resolve[T]()
       at UCommerce.Infrastructure.ObjectFactory.Resolve[T]()
       at UCommerce.EntitiesV2.PurchaseOrder.GetRepo()
       at UCommerce.EntitiesV2.PurchaseOrder.All()
       at UCommerceConsole.Program.Main(String[] args) in c:\Development\Console\
    mmerce Console\UCommerce Console\src\UCommerceConsole\Program.cs:line 18

     

    any ideas what im missing? been at it for hours

  • lj 81 posts 425 karma points
    Sep 06, 2013 @ 16:54
    lj
    100

    Solved the problem:

    I was adding a new <connectionStrings><add connectionString="...your connection details here" /></connectionStrings> section in the app.config file when what I needed to do was just update the connectionString in the runtimeConfigurationsection section of the app.config file.

    ie <runtimeConfiguration connectionString="...your connection details here" />.

  • Timothy Beutels 11 posts 31 karma points
    Sep 10, 2013 @ 22:21
    Timothy Beutels
    0

    We're trying the same (standalone console app) and are hitting a snag.

    Since you got it working I was wondering if you could have a quick look?
    We're on Umbraco v6.1.5 and uCommerce v4.0.30319.

    The setup of our console app looks exactly like the tutorial - we've referenced all dll's included with uCommerce, installed UmbracoCms.Core from NuGet, included the required folders, updated the app.config and changed the connectionString. The config's are detected - if we leave them out we get an error about them not being present.

    The problem is that we get an exception from Castle Windsor not being able to find a mapping for a uCommerce dll.
    Which is odd - since the website (were we copied the config's from) works fine and all dll's are included.

    This is the exception (altough probably not really helpful in this case).

    Could not convert string 'UCommerce.Pipelines.GenericPipeline`1[[UCommerce.EntitiesV2.Definitions.IDefinition, UCommerce]], UCommerce' to a type.
    -> Object reference not set to an instance of an object."
     

     

    Are you using different versions of Umbraco and/or uCommerce?
    Would you mind sharing a (dumbed down version) of the solution that worked for you? 

  • lj 81 posts 425 karma points
    Sep 11, 2013 @ 00:05
    lj
    0

    What I did was down loaded the code at the end of the tuturial http://www.publicvoid.dk/UsingTheUCommerce3APIInAWindowsApplication.aspx.

    This is a very basic console application which is ideal for a starting point.

    The only change you need to make is to the connection string found at <runtimeConfiguration connectionString="...your connection details here" />. found in the app.config file. If you can get that working then you could biuld from there.

    The problem you are having sounds similar to mine. Probably to do with a version off one of the dlls that were copied over not being compatable. you could try using the dlls in the app from the tutorials instead of your umbraco instance.

     

    Hope this helps.

     

  • Timothy Beutels 11 posts 31 karma points
    Sep 11, 2013 @ 11:16
    Timothy Beutels
    0

    Thanks for your reply!

    We've worked around the problem by 'warming up' the API.

    The first (few?) API call(s) fails because Castle Windsor has not initialised yet - so as a workaround we just call the api until it doesn't throw the exception anymore.
    From that point all calls do go through.

    I assume in uCommerce v4 the initialisation happens on startup of the web app or upon first call.
    We'll need to look into it further to confirm, but for now we can continue development with the workaround.

    Thanks again for getting back so soon! 

Please Sign in or register to post replies

Write your reply to:

Draft