Debugging Vegas script using Microsofts CLR Debugger

dust wrote on 7/19/2004, 4:43 AM
I was looking for a way to use Microsofts CLR debugger 2003 (or Visual Studio .NET 2003) to smybolically (!) debug Vegas scripts. Actually I did find a way using a library, and this might be interesting to others as well. I described my path in this thread, but only in German (it's a German forum). But the source codes on the page should tell you enough. In short, it works like this:

the source code needs to be in a separate library, so it must be wrapped into a "package" structure in a separate file (that I called gugus.js) containing a static (pure virtual) class. Because global Vegas variables (like Vegas and ScritpFile) are not known there, they have to be passed to the class using a static init() function. The code to be debugged was stuffed into a static code() function. The init() function also contains the call to "debugger;" which just starts the debugger and sets a breakpoint. This source file must be compiled independently using the jsc instruction given in the other page. Note the /debug" option, which will produce a "gugus.pdb" file (containing link between source and virtual-machine instructions).

In addition, a wrapper script (called wrapper.js) plus its wrapper.xml need to be created and then called from within Vegas.

Though this is working, it is a lengthy process. So I'm wondering if there is maybe an easier way? All that's really needed (I think) is a way to tell Vegas to write a ".pdb" file when compiling the script. I tried to put something like

<configuration>
<system.runtime.remoting>
<application>
<compilation debug="true"/>
</application>
</system.runtime.remoting>
</configuration>

into a Vegas50.config and Vegas.config file, but this didn'^t make any difference. Any ideas/suggestions maybe?

Comments

rcampbel wrote on 7/19/2004, 4:08 PM
If you have Visual Studio .Net, then you are much better off writing your scripts in C# instead of JScript. You can use all of the IDE support including the debugger very easily.

Basically you have a small JScript stub that calls a method in your C# dll. I use something like this:

import MyNamespace;
Main.Start(Vegas, ScriptFile);

You also have to put your C# dll in the .config file in order for Vegas to find it.

To debug, just setup the project config to launch Vegas with the following arguments:

-SCRIPT:"path to script file/script.js"

Then you can set breakpoints in the source, right click on the project and click Debug/Start New Instance. Vegas will be launched, your script will run, and you can debug!

This is a much better way to write scripts!

Randall
dust wrote on 7/22/2004, 12:05 AM
Yes, I had this idea too :-) actually, what you describe works perfectly using Jscript as well (including debugging).

I tried using C# instead. The problem I got there is I wasn't able to import Sony.Vegas. Maybe you know how to do this?

Using JScript, I can use a (stupid) code in a file test.js

import Sony.Vegas;
package testP {
class testC {var e:TrackEvent;}
}

and compile it successfully using

jsc /t:library /lib:"D:\Program Files\Sony\Vegas 5.0" test.js

The "/lib" argument tells jsc where to look for Sony.Vegas.

If I use a similar C# soure test.cs like:

using Sony.Vegas;
namespace testP {
class testC {TrackEvent e;}
}

and try to comile it using:

csc /t:library /lib:"D:\Program Files\Sony\Vegas 5.0" test.cs

I get the error message:

test.cs(1,7): error CS0246: The type or namespace name 'Sony' could not be found
(are you missing a using directive or an assembly reference?)
test.cs(3,16): error CS0246: The type or namespace name 'TrackEvent' could not
be found (are you missing a using directive or an assembly reference?)

I also tried it using the IDE, called the project properties, and added "D:\Program Files\Sony\Vegas 5.0" to "Common Properties"/""References Path". I get the same problem there too.

[EDIT]: I just found out how to do it in the IDE: In the solution explorer, right clock on "References", and chosing "Add reference", you can browse ro "Sony.Vegas.dll" and so make above code compile. I still don't know how to do this using the command line, but it's working in the IDE now. [EDIT end]

Any ideas what I'm doing wrong? Would be nice to write code in C# of course.
rcampbel wrote on 7/22/2004, 6:17 AM
Correct, you need to set a reference to the Sony.Vegas.dll. For the command line, just add Sony.Vegas.dll to the path that you have and you will have it.

csc /lib:"D:\Program Files\Sony\Vegas 5.0\Sony.Vegas.dll"

Randall
dust wrote on 7/22/2004, 10:45 PM
Sorry, but this doesn't work in my case...


csc /t:library /lib:"D:\Program Files\Sony\Vegas 5.0\Sony.Vegas.dll" test.cs


tells me it can't resolve Sony.Vegas.dll (and yes, the path is correct). It doesn't matter if I pass the dll (as above) or just the directory. It's ok if it works in the IDE, but somehow it should also work in the CLI. It is working this way using jsc though.

Andy
rcampbel wrote on 7/23/2004, 11:17 AM
I'm sorry. I was reading the doc too fast. I use NAnt to do my command line builds and NAnt actually constructs the CSC command.

I think that you need the following:

csc /t:library /lib:"D:\Program Files\Sony\Vegas 5.0\" /reference:Sony.Vegas.dll test.cs

The lib is the path, and the reference is the name of the assembly. This is all documented in the .Net Framework SDK help (Reference/Compiler and Language Reference/C#/C# Compiler Options).

NAnt is a good build tool that you might want to check out: http://nant.sourceforge.net/index.html

Randall