简体   繁体   中英

The type or namespace name 'SqlWorkflowInstanceStore'

I'm building some basic workflow functionality in WF 4.0 with SqlWorkflowInstanceStore. I have added the right references and have tried switching from client profile but still the same problem:

I get the following error in the error list in Visual Studio 2010:

Error 1 The type or namespace name 'SqlWorkflowInstanceStore' could not be found (are you missing a using directive or an assembly reference?)

I'm stuck and have no idea how to fix this.

Here's the code:

using System;
using System.Linq;
using System.Activities;
using System.Activities.Statements;
using System.Activities.DurableInstancing;
using System.Runtime.DurableInstancing;
using System.Threading;

namespace mybasicwf4
{

    class Program
    {
        static void Main(string[] args)
        {
            string sqlPersistenceDBConnectionString = @"Data Source=.;Initial Catalog=PersistenceDatabase;Integrated Security=True";
            SqlWorkflowInstanceStore sqlWFInstanceStore = new SqlWorkflowInstanceStore(sqlPersistenceDBConnectionString);
            AutoResetEvent waitHandler = new AutoResetEvent(false);
            WorkflowApplication wfApp = new WorkflowApplication(new Workflow1());
            wfApp.InstanceStore = sqlWFInstanceStore;
            wfApp.Unloaded = (arg) =>
            {
                waitHandler.Set();
            };
            wfApp.PersistableIdle = (arg) =>
            {
                return PersistableIdleAction.Unload;
            };
            wfApp.Run();
            waitHandler.WaitOne();
        }
    }
}

I've encountered the same error in .Net 4 when working with Workflow persistence, so thought I'll share my findings

The type 'System.Runtime.DurableInstancing.InstanceStore' is defined in an assembly that is not referenced.

The namespace that we are trying to use is System.Activities.DurableInstancing, BUT the assembly that we need to reference is actually System. Runtime .DurableInstancing

I know right:D

Hope it helps people

Finally! I got it working.

After removing the references and adding them back in the error disappeared. I only wish I had tried this before.

:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM