Jerry-Malcolm wrote on 2/11/2023, 5:58 PM

Quick intro... I wrote a ton of scripts back in the Veg3-V13 era in jscript. Much of the reason I held back on moving forward to later versions of Vegas was the daunting task of converting everything in my workflow to c# when jscript was abandoned. But I've bit the bullet. I'm on V20 now and I'm in the process of converting. I have over 25 years programming Java. I know enough c# to be dangerous. But I'm likely to need a slight bit of help in a few areas of use c# in vegas.... Such as right now. I was charging along converting scripts until I got to a script that reads a windows shortcut (*.lnk). Worked fine in jscript. I researched the c# variation and it said I needed WshShell. I found an example that has a 'using IWshRuntimeLibrary;' statement. But when I try to run the script, I get "The type or namespace name IWshRuntimeLibrary could not be found..." Do I have this using statement wrong? Or do I need to add some library to Vegas in order to have the IWsh stuff available? I'm so close on this script... then on to the next one.

Thanks in advance.



jetdv wrote on 2/11/2023, 7:03 PM

JScript scripts still run just fine. You can still use them - just change "import Sony.Vegas;" to "import ScriptPortal.Vegas;" and they'll still run.

Did you put the DLL file in the same folder as the script?

You might need to do this:

1.8: How do I use my own .NET assembly from within a script?

By default, Vegas loads the following assemblies for every script that it runs:






These assemblies cover most of the classes that scripts will use. However, occasionally a script will need to use classes that are not defined in the assemblies above including ones you've written yourself. In these cases, scripts must have a configuration file that tells Vegas which extra assemblies to load.

Each script can have a configuration file that specifies extra .NET assemblies used by the script. The configuration file is an XML file with the same file name as the script except it has the '.config' extension appended. For example, if your script is named "MyScript.cs", its configuration file should be named "MyScript.cs.config". The configuration file must be in the same directory as the script.

The following provides an example of a configuration file for a script that references several extra assemblies:

Language: XML

<?xml version="1.0" encoding="UTF-8" ?> 
   <AssemblyReference resolver="local">LocalUtilities.dll</AssemblyReference> 

The root XML element of the configuration file is named ScriptSettings. This element can contain any number of AssemblyReference elements. The inner text of each AssemblyReference element contains the file name of an assembly DLL. For assemblies that are in the GAC (Global Assembly Cache... this includes most assemblies that ship with the .NET Framework), a full path is not required. The resolver attribute, when set to "local", tells Vegas to look for the referenced assembly in the same directory as the script. Otherwise, you should specify the full path to the assembly. The local resolver attribute allows you to distribute your script, its configuration file, and helper assemblies without hard coding any paths. You just need to keep them in the same directory.

One problem in the current release of Vegas is that VB scripts can not access assemblies in that are not either in the GAC or in the same directory as the Vegas executable. It is possible, however, to add your assembly to the GAC by using the gacutil program (See the .NET Framework documentation for more details). Alternatively, you can place a copy of your assembly in the Vegas install directory and use an AssemblyReference element similar to one that refers to an assembly in the GAC.