LoanCo is a sample loan app for a fictitious company that shows some common ways an application might interact with the DocuSign eSignature API. It shows three separate examples, each increasing in features and functionality:

Personal Loan – Basic embedded signing with a single signer on a single document

Not only can you tryout the functionality of each use-case in the live LoanCo sample app, but you can also download the code on GitHub to try for yourself or to act as a starting point for your own applications and integrations. We started by making the sample app code available in Node.js, but due to overwhelming demand, we just released it in C# as a Visual Studio 2017 solution too.

The LoanCo C# Approach

The design goal was to port the Node.js LoanCo sample app to C#, but not to increase the complexity by forcing you to install and configure a Windows web server with Internet Information Services (IIS). Node.js make serving web pages and responding to HTTP requests very simple without additional configuration. Additionally, if we make updates to the Node.js LoanCo sample, these changes can be easily migrated into the C# version (or other versions we may release). Therefore, we decided to keep the Node.js web code framework and only port to C# the code that calls the DocuSign API.

The downside to this approach is that there is no native way to make C# (.NET) calls directly from Node.js, so we implemented the Edge.js library (available as a NuGet package within Visual Studio 2017). Edge.js does the hard work of marshalling calls between Node.js and C#, which enabled us to focus solely on the C# porting.

The Visual Studio LoanCo Solution is comprised of two separate projects:

DocuSign CSharp LoanCo –C# project that can be run in one of two modes:

Class library – Generates the DocuSign.dll library that will be called by the Node.js project through the Edge.js library. This is useful when running or debugging the Node.js web UI.

Console Application – Useful for debugging the C# code, but will not invoke the Node.js web UI.

Sample-app-loanco-nodejs-master – Node.js project that started from the GitHub LoanCo source. Only these files from the routes folder were modified to remove the Node.js API-specific code:

loan-personal.js

loan-auto.js

loan-sailboat.js

Getting Started

To get started, follow these simple steps:

Install Node.js version 6.9.4 on a Windows computer. As of this writing, versions greater than 6.9.4 are not supported on Edge.js.

FAQ

Q: When compiling for the first time, I’m getting a “Cannot find module ‘edge’ error.

A: Open a node.js command prompt and run npm install edge

Running the Solution

To run the LoanCo Visual Studio Solution, simply press F5. it is set by default to build the C# project as a Windows Class library (see description above) and then start the Node.js web server. If this doesn’t work ensure you have these settings:

Set sample-app-loanco-nodejs-master.njsproj project as StartUp project.

Right-click the DocuSign CSharp LoanCo project and select properties.

Ensure Output type is Class Library.

Running the solution using Node.js as the web server won’t break in your C# code when you set breakpoints, but you can debug your code using message boxes. When the Node.js web server is running, open a browser and navigate to http://localhost:3801. Here’s what that looks like:

If you want to set breakpoints in your C# code and step through the C# code, you run the project as a Windows Console application (see description above) with these settings:

Set DocuSign CSharp LoanCo project as StartUp project.

Right-click the DocuSign CSharp LoanCo project and select properties.

Ensure Output type is Console Application.

Set Startup Object as DocuSign.Program.

Running the solution as a Windows Console application won’t invoke the Node.js web server, so you run each use-case in your C# code from Main(). If you navigate to this function, you’ll see prototypes for each of the three use-cases (loan types) to easily run them. Here’s what that looks like: