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 on your machine containing Workflow Studio 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

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. 

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. On the Solution tab, in the Code Tree, right-click anywhere and select New Folder.

  4. In the Add New Folder dialog that appears, type Common Code and click OK.

  5. Right-click the new folder and select Add Visual C# Source Item, then Add Class Source.

     

  6. 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.)

  7. Compile and publish your changes.

  8. In the workspace, close the Class Library, and when prompted, save and check in your changes.

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.

Edit the class in Visual Studio

  1. Open Visual Studio, and in the Source Control Explorer, navigate to your folder.

  2. Double-click the solution file for the project.

  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 the latest .NET framework.

  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.

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

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. 

IN THIS ARTICLE