Problem with Custom Command

Jerry-Malcolm wrote on 12/15/2024, 11:33 PM

I followed Ed (JETDV)'s videos on creating a custom command precisely, as far as I could tell. I've added a few controls to the command's dockable window control. No problems. Everything compiles successfully after a clean. But now when I try to open the CCTest.cs code in VS, I get that VS error screen that starts off with "To prevent possible data loss..." and it gives me an error Constructor on type 'ScriptPortal.Vegas.DockableControl' not found. It does not give an option to ignore and continue with the error. It has links for the call stack, MSDN help, and search forums. None of which is any use. I opened the CCTest.cs file outside of VS just to see if there was anything obvious. As far as I can tell, it is identical to the version at the end of the Custom Command video. I've checked all of the references, many times. The thing that is really confusing is that the class compiles. I changed spelling on a couple of things just to make sure the compiler was indeed compiling this class and the misspellings were correctly flagged. So it's compiling. But it absolutely will not open as a typical cs class in the VS editor. Just curious if anybody else has encountered anything like this and if there are resolutions. Thx.

Comments

bvideo wrote on 12/15/2024, 11:47 PM

You don't actually run the code bare (or directly under VS). None of the Vegas portal code is present, because compiling the code does not carry out linking to any method not in your code.

Your code is supposed to run as a "subroutine" under Vegas. So you start Vegas and then select your custom command from the appropriate menu.

There was at one time a way to start Vegas under VS and then do debugging of your code. Doesn't seem to work under recent Vegas and recent VS.

Jerry-Malcolm wrote on 12/16/2024, 6:42 AM

Thanks for the comment. But this has nothing to do with running the code. I understand debugging Vegas scripts/commands. The error occurs when I simply double click the CCTest.cs file in VS and try to edit it. I open the solution in VS, double click to edit CCTest.cs and get the error message.

jetdv wrote on 12/16/2024, 9:14 AM

@Jerry-Malcolm did you download the base custom command and then modify that? Or did you type in everything from scratch?

Based on the error message, it sounds to me like you haven't added the reference to SciptPortal.Vegas under references so it wasn't able to find the items under ScriptPortal.Vegas.

The base code download can be found in the description of Tutorial number 1. But you might have to change the pointer to the reference file to be the version of VEGAS you have installed. I think 18 was current as of the time of the creation of that tutorial.

bvideo wrote on 12/16/2024, 11:12 AM

The error dialog offers to show the "call stack": would you be able to post it here?

Jerry-Malcolm wrote on 12/16/2024, 11:21 AM

Ed, I downloaded and re-edited, following step by step along with the video. I finally realized I could press F7 in VS on the error message and get to the code. I definitely have the ScriptPortal.Vegas using statement in there. When I go to F7/Code and comment out the using, I get 17 errors, which I would expect. I uncomment the using statement and all references resolve. I then get a completely clean build. I've tried saving, closing the solution, rebooting, pushing to GitHub and re-pulling, making changes to other files in the project to force VS to re-autogen stuff, erasing the obj and bin folders. I even tried moving to a different machine with Vegas and VS installed. You name it. I think I tried it.

I wanted to post this just to make sure it wasn't some dumb mistake that you already understood and had a quick answer for. Looks like it's something related to my specific environment.

My biggest concern until now was that I had forgotten the F7 option to get to the code (remember, I'm a 30-yr Java/Eclipse guy... loving C#/VS.... but still figuring out the tricks). Now that I have figured out access to the actual code, I'm going to try to insert some breakpoints and see if I can hit them.

My current thought is that this is some sort of VS issue considering I get a clean compile. If I can work around it, I'll just move on. If I get other errors, hopefully those other errors will provide enough additional info to figure it out.

Thanks as always for your assistance. Love the videos!

Jerry-Malcolm wrote on 12/16/2024, 11:24 AM

Here's the call stack. Definitely gets down into the weeds. I'm not familiar enough with the inner workings to decypher any of this.

1 Error

Why am I seeing this page?

Constructor on type 'ScriptPortal.Vegas.DockableControl' not found.

 

Instances of this error (1)

1.Hide Call Stack

at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture)
at System.ComponentModel.Design.DesignSurface.CreateInstance(Type type)
at Microsoft.VisualStudio.Design.VSDesignSurface.CreateInstance(Type type)
at System.ComponentModel.Design.DesignerHost.System.ComponentModel.Design.IDesignerHost.CreateComponent(Type componentType, String name)
at System.ComponentModel.Design.Serialization.DesignerSerializationManager.CreateInstance(Type type, ICollection arguments, String name, Boolean addToContainer)
at System.ComponentModel.Design.Serialization.DesignerSerializationManager.System.ComponentModel.Design.Serialization.IDesignerSerializationManager.CreateInstance(Type type, ICollection arguments, String name, Boolean addToContainer)
at System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, CodeTypeDeclaration declaration)
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host)

jetdv wrote on 12/16/2024, 11:37 AM

I'm not talking about the "Using" statement. I'm talking about it being added as a reference - see my screenshot. Under "References" have you added it there?

bvideo wrote on 12/16/2024, 1:20 PM

The stack trace is looking like VS is trying to run your .cs file, not just compile it and certainly not editing it. Of course it shouldn't run without referencing your Vegas installation as the "start external program" in the debug section of your .csproj properties. And I don't know why it would want to run just by double clicking your source file.

Jerry-Malcolm wrote on 12/16/2024, 2:29 PM

Ed, I do have the reference as well. Missing the reference or the using will cause compile errors. I'm curious that the error says it can't find the constructor for ScriptPortal.Vegas. When the reference or using is removed, it says it can't find the class itself.

I've hit another problem (I'm usually more self-sufficient than this... :-(... ). I'll post that in another thread. I'd think it was just a bad install of VS 2022. But I've got the same problems on two different machines. Ed, I know you still use 2015 version. Is there a chance that some things might not work the same on 2022? I can't believe MS would do something like that. Just grasping at straws.