Application extension - "An invalid pointer...."

JohnnyB wrote on 6/27/2011, 6:06 AM
Has anyone seen/resolved this error when running an application extension?

"An error occurred during the current operation. An invalid pointer was specified".

Running on Vegas 10.0c 32bit or 64 bit, and producing a dll from the "Hello World" SDK sample with .Net2 on VS2010. I've tried compiling for 64bit or x86 (running on W7 64bit); and also tried running on Windows XP Mode. Also, putting the dll in various places. Same result. Would welcome any pointers(!), or alternative sample code which is known to work.

Thanks.

Comments

jetdv wrote on 6/27/2011, 10:42 AM
It might help to see the code where it is actually dying and also an idea of what that section of code is supposed to do.
JohnnyB wrote on 6/28/2011, 12:56 AM
Thanks, the code is the boilerplate "hello world" application extension from the SDK, appended below. I include a reference to the Vegas dll, and compile (with VS2010 and .net2) the code to a dll. I put the dll into one of the paths that Vegas looks at (the application data), and the relevant command shows up in the tools/extensions menu. When started, a message box is raised by Vegas with the error message - I don't get any debugging.

c#

using System;
using System.Collections;
using System.Windows.Forms;
using Sony.Vegas;

public class SampleModule : ICustomCommandModule {

public void InitializeModule(Vegas vegas) { }

public ICollection GetCustomCommands() {
CustomCommand cmd = new CustomCommand(CommandCategory.Tools, "SampleToolCommand");
cmd.DisplayName = "Hello World";
cmd.Invoked += this.HandleInvoked;
return new CustomCommand[] { cmd };
}

void HandleInvoked(Object sender, EventArgs args) {
MessageBox.Show("hello world");
}
}


jetdv wrote on 6/28/2011, 3:15 PM
What if you move the "CustomCommand" line outside of the routine like this?

using System;
using System.Collections;
using System.Windows.Forms;
using Sony.Vegas;

public class SampleModule : ICustomCommandModule
{
CustomCommand cmd = new CustomCommand(CommandCategory.Tools, "SampleToolCommand");

public void InitializeModule(Vegas vegas)
{
}

public ICollection GetCustomCommands()
{
cmd.Invoked += this.HandleInvoked;
cmd.DisplayName = "Hello World";
return new CustomCommand[] { cmd };
}

void HandleInvoked(Object sender, EventArgs args)
{
MessageBox.Show("hello world");
}
}



(I didn't actually test this, though)
JohnnyB wrote on 6/29/2011, 10:20 AM
Thanks for your suggestions - I was wondering whether one might need to persist the object beyond the method call, but it appears that Vegas does this.

The error was in my VS2010 project References - I had incorrectly referred to the V9 32 bit Vegas.dll, and tried to run from V10 64 bit. My bad, but hopefully this will help anyone else who's got this error message.

Thanks again for your help.
jetdv wrote on 6/29/2011, 12:25 PM
Not sure why that would be an issue. My main projects reference the Vegas Pro 8.0a 32-bit DLL and it works fine in 8.0a and newer, 8.1, 9.0 32-bit and 64-bit versions, and 10.0 32-bit and 64-bit versions.
JohnnyB wrote on 6/29/2011, 2:15 PM
I guess the why's are sometimes hard to get at, at least now I've got a working sample to mod which makes it much easier - the killer is when nothing works! thanks again for your suggestions.

Good to know the compatibilities, I was afraid I'd have to compile multiple versions.
Cheesehole wrote on 5/24/2013, 1:10 AM
I made an extension that is giving my friend this error. It was working fine and then just started happening. He's also using Vegas 10 so I'm wondering if it is related.
Gary James wrote on 5/24/2013, 8:39 AM
I've created an example Vegas extension project written for .NET 2.0 and VS2010. It references the Vegas v8.0 DLL so it is compatible with all versions of Vegas since v8. I also compile with the Any CPU option selected ( although I've been told this isn't necessary ). A download link to the project is located on my Timeline Tools main web page at Timeline Tools Vegas Extension.

The Extension includes a State Machine that resides between the Vegas Events and the Events the S.M. fires into the application. But you can remove this code if you want and use the Vegas Events directly. I've placed this on-line because examples of how to create a Vegas Extension are very scarce. And I wanted to share the knowledge I've learned from designing my Timeline Tools Extension with others. This example project also represents the help I've received with my Extension from many very knowledgeable people on this list; like Edward Troxel, the mind behind JetDV and Excalibur.

There are also a couple suggestions I'd like to make regarding debugging your Vegas Extension.

(1) You should Start Vegas without the extension already running. That way you can set your breakpoints in your start-up code and make sure they'll get hit when you launch your extension manually from inside Vegas.

(2) Don't start Vegas from inside Visual Studio. I've never been able to successfully debug my extensions this way. Start Vegas outside VS2010.

(3) When Vegas is running, select the VS2010 [Tools / Attach to Process ...] menu item, and then select Sony Vegas from the list of running processes.

(4) Make sure you have the Common Language Runtime Exceptions, Managed Debugging Assistants, and Native Run-Time Checks checkboxes checked in the Debugging Exceptions dialog accessed via the [Debug / Exceptions ...] menu item.

(5) With Vegas running and attached to the debugger, set your Extension breakpoints and then start the Extension from inside Vegas.