Editing Class Libraries in Visual Studio

If you want to take advantage of the speed and Intellisense features in Visual Studio, you can edit class library code there, and add folders and files. These automatically update in Workflow Studio.

There are still some things that you can do only in Workflow Studio:

  • Add references (these do not update in Workflow Studio when you add them in Visual Studio)
  • Publish your code
  • Proprietary designs like workflows and activities

Overview of a Workflow Studio class library

First, let's explore an existing class library. In Workflow Studio, on the Workspace tab, expand WCF Services, which already contains a Class Libraries package.

Now open File Explorer and navigate to a path like this: C:\Source\EID\EmpowerID\WFSPackages\WCF Services\Class Libraries. Notice that it contains the following:

  • *.cslib files corresponding to the ones in the WCF Services > Class Libraries package
  • *_Project folders for each of the class libraries represented with a cogwheel icon

In Workflow Studio, if you double-click Test Rick Class Library to open it, you can see all of the references, forms and classes contained in the class library in the Code Tree tab that appears to the right.

Back in File Explorer, open one of the project (*_Project) folders and notice that it contains: 

  • All of the folders under the Classes node in Workflow Studio
  • All of the C# (*.cs) files under the Classes node
  • A C# project file (*.csproj)
  • A Visual Studio solution file (*.sln)

Also note what it does not contain: References. 

You can double-click the solution file, in this case TestRickClassLibrary.sln, to open the solution in Visual Studio for editing.

To add a new class library in Workflow Studio

  1. In Workflow Studio, on the Workspace tab, expand WCF Services, right-click Class Libraries, and select Add New Item, then EmpowerID Class Library.

  2. In the Add New Class Library dialog that appears, enter a name for your class library and click OK.

  3. A C# Editor tab appears with namespace and class stubs in place, and the Code Tree is populated.

  4. On the Solution tab, in the Code Tree, right-click anywhere and select New Folder.
  5. In the Add New Folder dialog that appears, type Common Code and click OK.

    The new folder appears under the Classes node. (Repeat as necessary, or you can do it in Visual Studio.)
  6. Right-click the new folder and select Add Visual C# Source Item, then Add Class Source.

  7. In the Add New Class dialog that appears, enter a name for the class and click OK.

    The new class appears in the Common Code folder. (Repeat as necessary, or you can do it in Visual Studio.)
  8. Compile and publish your changes.
  9. In the workspace, close the Class Library, and when prompted, save and check in your changes.

  10. Close Workflow Studio.

    If you have the class library open in both Workflow Studio and Visual Studio, you may inadvertently overwrite your changes. To avoid this, close one before opening the other.

To edit the class in Visual Studio

  1. Open Visual Studio, and in the Source Control Explorer, navigate to your folder, in this case: 
    C:\Source\EID\EmpowerID\WFSPackages\WCF Services\Class Libraries\TestRickClassLibrary_Project
  2. Double-click the solution file for the project: TestRickClassLibrary.sln
  3. A dialog appears, asking whether you want to bind the solution to source control. Click Yes.

  4. In the Change Source Control dialog that appears, select the solution and click the Bind button.

  5. Select the class library on the second line and click Bind again, then click OK.

  6. In Solution Explorer, right-click the project (just under the solution) and select Properties.

  7. In the Properties window that appears, change the Target framework to .NET Framework 4.7.2.

  8. A dialog informs you that you must close and reopen the project, and asks whether you are sure you want to change it. Click Yes, and then close and reopen the project.
  9. In Solution Explorer, expand the Common Code folder and click CustomerClass.cs to open it for editing.

  10. Now you can add code, classes, and folders as needed in Visual Studio.

    References added in Visual Studio are not saved to Workflow Studio, so you must add them in Workflow Studio.

  11. When you are finished coding, from the Build menu, select Rebuild YourClassLibrary to compile the DLL and bring in references.

    Now you are ready to publish the class library in Workflow Studio, which moves it into EmpowerID and puts it in the database register.

To publish the class library in Workflow Studio

  1. In Workflow Studio, open your class library from the shortcut on the Startup page. Any changes you made in Visual Studio (except for any references you may have added) appear in Workflow Studio.
  2. In the Code Tree to the right, add any necessary references.
  3. Compile and publish your changes. Your Visual Studio-edited code is moved into EmpowerID, and into the database register.

In this article