Using HashSet type in a Vegas Script

Cantersoft wrote on 11/17/2021, 10:12 PM

I need to create a list that discards duplicate entries, so I wanted to use HashSet, like this:

HashSet<int> noDuplicatesList = new HashSet<int>();

However, doing this returns the error "The type or namespace name 'HashSet' could not be found (are you missing a using directive or an assembly reference?)". This error does not occur outside of Vegas's scripting API, which means there must be something specific to Vegas resulting in this issue.

In case it matters, I am using Vegas Pro 17.


jetdv wrote on 11/18/2021, 9:05 AM

Just to cover the basics, I assume you have this listed?

using System.Collections.Generic;

I've never tried using that in a VEGAS script.

Cantersoft wrote on 11/18/2021, 11:41 AM

Yeah. Just now I tried making another script that only creates a HashSet variable, but even this doesn't seem to work for some reason.

using System.Collections.Generic;
using ScriptPortal.Vegas;public class EntryPoint{
    Vegas currentVegasApp;
    public void FromVegas(Vegas vegas){
        HashSet<int> noDuplicatesList = new HashSet<int>();
jetdv wrote on 11/18/2021, 12:59 PM

Out of curiosity, what if you change it to:

using System.Collections.Generic;
using ScriptPortal.Vegas;
public class EntryPoint
    Vegas currentVegasApp;
    public void FromVegas(Vegas vegas)
        System.Collections.Generic.HashSet<int> noDuplicatesList = new System.Collections.Generic.HashSet<int>();


Cantersoft wrote on 11/18/2021, 2:27 PM

This time;

The type or namespace name 'HashSet' does not exist in the namespace 'System.Collections.Generic' (are you missing an assembly reference?)

Incidentally, not sure what happened with the code snippet I pasted in my earlier comment. I had line breaks in my original code but whatever.

jetdv wrote on 11/19/2021, 7:29 AM

The "insert code" on this forum does that sometimes. I'm used to seeing that happen.

What are you editing in? Or are you just using something like NotePad and then running it in VEGAS? In Visual Studio, it was happy with adding "System.Collections.Generic." in front of "HashSet" while set to ".NET 4.0" but I did not try running it in VEGAS. I have found that, sometimes, you have to specify where the item is located as the same item can be in multiple places. That's why I thought it might be helpful to specify.

Cantersoft wrote on 11/19/2021, 8:02 AM

Yeah, I was just typing into Notepad and running the code in Vegas. I tried using Visual Studio in the past but it was very confusing for me. Do you think creating the code in Visual Studio vs. in Notepad would make any difference for how it runs in Vegas?

jetdv wrote on 11/19/2021, 1:16 PM

If running as straight text, probably not. If running a compiled DLL, maybe. Go take a look at all of the tutorials on my website at and it will show you how to get started using Visual Studio for writing scripts for VEGAS. Here's a good starting point:

Or you can also go straight to the YouTube channel - here's the VEGAS playlist:

As I said, I've never tried using HashSet and haven't tested it either.

altarvic wrote on 11/20/2021, 5:43 AM

Create the text file yourscriptname.cs.settings with the following content:

<?xml version="1.0" encoding="UTF-8" ?>

The configuration file must be in the same directory as your script.

Cantersoft wrote on 11/20/2021, 6:39 AM

After adding the *.settings file, I'm still getting the same error message;

The type or namespace name 'HashSet' does not exist in the namespace 'System.Collections.Generic' (are you missing an assembly reference?)

altarvic wrote on 11/20/2021, 7:11 AM

It works here. Check the name of the settings file. If your script is MyScript.cs, the name of the settings file must be MyScript.cs.settings (double extension)

Cantersoft wrote on 11/20/2021, 9:05 AM

I have done this. I just recorded a video of my process.

jetdv wrote on 11/20/2021, 10:02 AM

I just tested with your two files in both 17 and 19 and neither worked for me either. I did not try a compiled version.