VC-4: Breaking out of the Sandbox

One of the coolest features of the new 4-series platform is Crestron has removed the sandbox environment. We’re now free to use modern tools and languages to develop for their devices! In this post, I’ll walk through how to create a new project in VS2019 for the VC-4.

No longer stuck in 2008!

These instructions work the same whether you’re running VS2017 or VS2019. There’s a free community edition that we can use.

Open Visual Studio and select Create a new project:

You might have to search for the correct project type, but what we want to create is a Class Library (.NET Framework). Once you’ve used it once, it will show up in the Recent project templates list:

Fill in some details about the project and hit Create:

Once the solution opens, right-click its name in the Solution Explorer and select Manage NuGet Packages for Solution:

The next window allows you to select which packages you want to include as part of your solution. Select Browse then type in crestron to find the package we want (step 1). Then select Crestron.SimplSharp.SDK.Program (step 2). Add this package to our project (step 3), and click Install (step 4).

A confirmation window will open asking if you want to make changes to this project. Click OK.

You also will need to accept Crestron’s license:

You can now go to the Solution Explorer and delete the Class1.cs file that was initially created with the solution:

First thing I like to do at this point is Build Solution (Build menu > Build Solution) to make sure all the necessary references were picked up. Hopefully everything builds and you have zero errors.

Let’s replace ControlSystem.cs with this code, load it to our VC-4 and make sure it starts up by checking the error log on our server:

using System;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.CrestronThread;

namespace VcTest2
{
    public class ControlSystem : CrestronControlSystem
    {
        public ControlSystem()
            : base()
        {
            try
            {
                Thread.MaxNumberOfUserThreads = 20;
            }
            catch (Exception e)
            {
                ErrorLog.Error("Error in the constructor: {0}", e.Message);
            }
        }

        public override void InitializeSystem()
        {
            try
            {
                ErrorLog.Notice("\nI'm free, no more sandbox for me!\n");
            }
            catch (Exception e)
            {
                ErrorLog.Error("Error in InitializeSystem: {0}", e.Message);
            }
        }
    }
}

Checking in syslog, I can see our message printed:

Going forward with the VC-4 testing, I’ll stick to VS2019 so we can try out some cool things. Unfortunately, anything running on the 3-series will continue to be programmed in VS2008. Since I plan to keep writing posts for both, I’ll tag the posts with which series it’s intended for.

If you really want this code (even though it does absolutely nothing), it’s available on GitHub.

3 thoughts on “VC-4: Breaking out of the Sandbox

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s