Adding a 3rd party c# assembly reference

Jan Rogowski wrote on 8/22/2012, 5:26 AM
Does anybody know if I need to do anything to get Vegas to see a 3rd party assembly reference?

I'm trying to have a Vegas script interact with a mySQL database using mysql.data.dll which I have installed and have working perfectly in other compiled c# apps. I'm using VS2010.

Example script code:



using System;
using System.IO;
using System.Windows.Forms;
using Sony.Vegas;
using MySql.Data;
using MySql.Data.MySqlClient;


class EntryPoint
{
Vegas vegas;

public void FromVegas(Vegas _vegas)
{
vegas = _vegas;

addData("ONE", "TWO", "THREE");
}

private void addData(string _XXX, string _YYY, string _ZZZ)
{
MySqlConnection conn = null;
MySqlDataReader rdr = null;

conn = new MySqlConnection(@"server=10.1.1.1; userid=JAN; password=PASSWORD; database=projectdb;");
conn.Open();

MySqlCommand cmd = new MySqlCommand();
cmd.Connection = conn;
cmd.CommandText = "INSERT INTO Table(XXX, YYY, ZZZ) VALUES(@XXX, @YYY, @ZZZ)";
cmd.Prepare();

cmd.Parameters.AddWithValue("@XXX", _XXX);
cmd.Parameters.AddWithValue("@YYY", _YYY);
cmd.Parameters.AddWithValue("@ZZZ", _ZZZ);
cmd.ExecuteNonQuery();

if (rdr != null) rdr.Close();
if (conn != null) conn.Close();
}

}



Everything works fine in VS. I know the c# code is good as it's cut and pasted from other working projects. But when I run the script in Vegas it can't find the mysql reference. It complains:


"The type or namespace name 'MySql' could not be found (are you missing a using directive or an assembly reference?)"


I'm guessing I need to copy the dll file somewhere for vegas to find it?

Comments

Gary James wrote on 8/22/2012, 8:11 AM
Jan, I don't believe this will work in a non-compiled Vegas script. If you compile your code into a DLL, and then reference that compiled script DLL from Vegas, that should work.

Essentially Vegas supports:

1. non-compiled text scripts.
2. compiled DLL scripts.
3. And in Vegas versions 8.x and above, Vegas supports Add-In extension DLL's.

What you want to do can only be done using options 2 or 3.
Jan Rogowski wrote on 8/22/2012, 8:53 AM
Hey Gary

Could you elaborate on Add-In extension DLL's please? I tried dropping

MySql.Data.dll

in:

C:\ProgramData\Sony\Vegas Pro\11.0\Application Extensions

and rebooted Vegas but still no joy.
Gary James wrote on 8/22/2012, 10:47 AM
Jan, To do what you want to do, you'll have to create a compiled DLL. There is no other way to get your mySQL reference into a script. Vegas accepts scripts that are either text files with an extension of .js, .cs or .vb., or it accepts DLLs that contains the entry points for a Vegas Script. Simply place the DLL in the same directory where you save your text scripts. Vegas will detect it and display it in the scripts menu.

Regarding Add-In Extensions. A Vegas script is a modal piece of code. You start the script. It does its job. And it ends. A Vegas Add-In extension is a modeless piece of code. You start it. And it present a display window that can be docked inside Vegas. From then on it does nothing until you interact with the controls on the window. Finally, it can be closed by the user when it is no longer needed. Excalibur, Vegasaur, Ultimate-S, and my free Vegas utility Timeline Tools are all Vegas Extensions.

The Timeline Tools utility web page contains an example Visual Studio project that shows how to create a Vegas Extension.
Jan Rogowski wrote on 8/23/2012, 3:23 AM
Thank you Gary, that's incredibly useful. Much better than the API docs!
Jan Rogowski wrote on 8/27/2012, 9:09 AM
To conclude the thread... I got vegas communicating to a mysql database by referencing the mysql.data module within a script compiled into a dll and by including mysql.data.dll into the same folder.

Thanks Gary!
Mikee wrote on 12/31/2014, 10:57 AM
Since this thread is older, perhaps something has changed since the last post.

According to the SDK v10.0
http://www.sonycreativesoftware.com/download/link?id=4746.1
Section 1.8: How do I use my own .NET assembly from within a script?

---

You can use a .config file to work with 3rd party references. See docs. This worked for me using an ExifLib.dll from http://www.nuget.org/packages/ExifLib/.