Error 0x80070002 (message missing) on first script

VegaMega wrote on 11/28/2023, 4:34 PM

Following the scripting FAQ in Visual Studio 2022 with C# I made the Hello World example from 1.14.

Despite some differences in VS 2022, I got it compiling and starting Vegas as the debugger. In Vegas I go to tools, start script and select my debug dll file -> An error occured during execution of the script. Error 0x80070002 (message missing).

System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
   at System.Reflection.RuntimeAssembly.GetExportedTypes()
   at ScriptPortal.Vegas.ScriptHost.ScriptManager.Run(Assembly asm, String className, String methodName)
   at ScriptPortal.Vegas.ScriptHost.RunScript(Boolean fCompileOnly)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

 

As my code is extremely simple (see 1.14 in scripting FAQ), there can be nothing wrong there..... So what is?

Using Vegas Pro 21.0 (downloaded today) trial version (to see if this scripting meets my needs) on Win11, 23H2 all updated, no other problems with the machine.

After the error message, Vegas completely crashes.... but this seems unrelated and caused by me running it not on screen #1, see: https://www.vegascreativesoftware.info/us/forum/crashes-all-the-time--143650/

 

Edit: It only happens (always) when running the .dll. When running the .cs it works. So something in my VS2022 project settings causes a file to be not found by vegas..... please help!

 

Edit2: 0x8007002 basically means that it cannot find a file and the System.IO.FileNotFoundException contributes to that statement. So I took ProcessExplorer from SystemInternals and with help of some filtering I was able to pin down a couple of NAME NOT FOUND or NO SUCH FILE errors generated by Vegas:

1) C:\Users\VegaMega\AppData\Roaming\VEGAS\HubDB\VegasUtilities.msalcache.bin3

=> this one I could fix by logging into VegasHub but that did not fix my problem

2) X:\project\VegasPro\Trial02\Trial02\bin\Debug\net8.0\Trial02.dll.config

3) X:\project\VegasPro\Trial02\Trial02\bin\Debug\net8.0\Trial02.xml

4) X:\project\VegasPro\Trial02\Trial02\bin\Debug\net8.0\System.Runtime.dll

5) X:\project\VegasPro\Trial02\Trial02\bin\Debug\net8.0\System.Runtime.exe

And also a couple of registry NAME NOT FOUNDs:

a) HKLM\SOFTWARE\Microsoft\Fusion\PublisherPolicy\Default\v4.0_policy.8.0.System.Runtime__b03f5f7f11d50a3a

b) HKLM\SOFTWARE\Microsoft\Fusion\PublisherPolicy\Default\policy.8.0.System.Runtime__b03f5f7f11d50a3a

c) HKLM\System\CurrentControlSet\Control\DeviceClasses\{53f5630d-b6bf-11d0-94f2-00a0c91efb8b}\Properties

 

I suspect 4) and 5) the most. But really not sure why they are not there or should be there.... also a) and b) are really interesting as the hexnumber b03f5f7f11d50a3a matches the PublicKeyToken from the exception details.

 

Anyone from support to comment on this?

 

Comments

jetdv wrote on 11/29/2023, 9:33 AM

I would recommend you go through my tutorials and start with the base scripts I have listed there. A big issue with the newer versions of Visual Studio is that you have to make sure you choose the "right" beginning option which is much harder to find. I'm actually still using Visual Studio 2015 (for multiple reasons)

  1. It's really easy to choose the beginning preset.
  2. I have the full installer downloaded making it easy to add to new machines without needing to download everything each time.
  3. Debugging works correctly

p.s. you want .NET 4.x

VegaMega wrote on 11/29/2023, 5:25 PM

I would recommend you go through my tutorials and start with the base scripts I have listed there. A big issue with the newer versions of Visual Studio is that you have to make sure you choose the "right" beginning option which is much harder to find. I'm actually still using Visual Studio 2015 (for multiple reasons)

  1. It's really easy to choose the beginning preset.
  2. I have the full installer downloaded making it easy to add to new machines without needing to download everything each time.
  3. Debugging works correctly

p.s. you want .NET 4.x

I am basically doing the same as in your videos. It just that in VS 2022 some things are different. I was making a guide for it and post it here when I have it working.

That last line of your post is very very interesting because Visual Studio 2022 does not include .Net 4.0 - 4.5.1 because these versions are no longer supported...... This now will be my main suspect for this problem. Not sure how to fix that though but Google or ChatGPT may hopefully tell me..

jetdv wrote on 11/30/2023, 7:05 AM

I've tested and gotten it to work (as per my tutorials) in both VS2015 and VS2019. I have not tested VS2022. For my tutorials, this is my properties (.NET 4.8):

VegaMega wrote on 11/30/2023, 3:05 PM

Just found out the by selecting 'class library (.Net Framework)' instead of 'class library' that I do have the option for .Net 4.8. Also after compiling, I could run the .dll file in Vegas without a problem. So the good news is that I can compile a working .dll now.

However there is a new problem: Setting Vegas210.exe as the debug executable, just as I did before, now does not start Vegas..... For a few seconds it is busy and then debugger stops without any message or error.... the whole exercise with the .dll is to get debugging to work, else I could just run the .cs file.

jetdv wrote on 11/30/2023, 6:37 PM

Debugging was an issue for me with 2019 - it would start VEGAS and everything would run but all of the tabs were blank. With 2015, everything just works which is one of the main reasons I'm still using VS2015.

And, yes, it's very important which "class library" you pick which I demonstrated using 2019.

lucas-v wrote on 12/24/2023, 8:54 AM

Thank you for these posts! I was struggling to find why I got the same FileNotFoundException with Visual Studio 2022 and this fixed it :D

jetdv wrote on 12/24/2023, 1:07 PM

@lucas-v glad to hear these posts are helpful.

VegaMega wrote on 9/28/2024, 5:45 PM

I started this post a couple of months ago and found myself having the same problems again and trying to find a solution for it again. So it's time to write it down so everybody can benefit.

Setting up Vegas Scripting in Visual Studio 2022

  1. Create a New C# Class Library Project
    1. Open Visual Studio 2022.
    2. Create a New Project:
    3. Click on "Create a new project".
    4. Search for "Class Library" and select "Class Library (.NET Framework)". Vegas Pro scripting requires the .NET Framework, not .NET Core or .NET 5/6+.
    5. Configure Your Project:
      • Project Name: e.g., VegasProScriptingExample
      • Location: Choose a suitable directory.
      • Framework: Select .NET Framework 4.8 (ensure compatibility with Vegas Pro 22.0).
    6. Click "Create" to generate the project.
  2. Add References to Vegas Pro API

    1. Right-Click on "References" in the Solution Explorer and select "Add Reference...".

    2. Browse to the Vegas Pro Scripting DLL:

    3. Click on the "Browse" tab.

    4. Navigate to C:\Program Files\VEGAS\VEGAS Pro 22.0\

    5. Select ScriptPortal.Vegas.dll and click "Add".

    6. Ensure the Reference is Added:

      • In the References list, you should see ScriptPortal.Vegas listed.

  3. Configure Project Properties

    1. Right-Click on the Project in Solution Explorer and select "Properties".

    2. Set Assembly Information:

      1. Navigate to the "Application" tab.

        • Ensure the "Target framework" matches what Vegas Pro expects (e.g., .NET Framework 4.8).

      2. Build Configuration:

        • Go to the "Build" tab.

        • Set "Platform target" to x64 since Vegas Pro is a 64-bit application.

  4. Implement the Script

    1. Open the Class File:

      1. By default, Class1.cs is created. You can rename it as desired.

    2. Implement the Vegas Script Interface:

      • using System;
        using ScriptPortal.Vegas;
        
        namespace VegasProScriptingExample
        {
            public class EntryPoint
            {
                public void FromVegas(Vegas vegas)
                {
                    // Example: Display a message box
                    System.Windows.Forms.MessageBox.Show("Hello from Vegas Pro Script!");
        
                    // Your scripting logic here
                }
            }
        }
        
      • Important: The entry point class must be named EntryPoint and contain a method FromVegas that takes a Vegas object as a parameter.

  5. Add Necessary References for UI Elements (Optional, but needed for the above sample script):

    1. If you plan to use UI components like message boxes, ensure you add references to System.Windows.Forms.

    2. Right-click "References" → "Add Reference..." → "Assemblies" → "Framework" → Select System.Windows.Forms and click "OK".

  6. Build the Solution:

    1. Click on "Build" → "Build Solution" or press Ctrl + Shift + B.

 

This is enough to run the script from within Vegas. So open Vegas, go to Tools, Scripting, Run Script and browse to your projects output folder, e.g. d:\projects\MyVegasScript\bin\debug\ and select the .dll file that was generated.

 

Setting up Debugging - Method 1 (not yet working)

  1. In VS 2022, open the Debug menu, the bottom entry is 'MyProjectName Debug Properties', click it. (Can also be reached through project properties and then clicking the Debug entry on the left)
  2. Select 'Start external program' and point it to the Vegas executable,
    • e.g. C:\Program Files\VEGAS\VEGAS Pro 22.0\vegas220.exe
  3. Add command line arguments:
    • -SCRIPT:d:\projects\MyVegasScript\bin\debug\MyScriptName.dll
  4. Run (F5)
  • This is not working! Vegas exits with code 0, no script is run! I have not found a solution to this! Anyone?

 

Setting up Debugging - Method 2 (not really debugging, but a good time saver)

  1. In your script add this line directly in the FromVegas function:
    1. vegas.UnloadScriptDomainOnScriptExit = true;
    2. So it looks like:
    3.         public void FromVegas(Vegas vegas)
              {
                  vegas.UnloadScriptDomainOnScriptExit = true;
      
                  // Example: Display a message box
                  System.Windows.Forms.MessageBox.Show("Hello from Vegas Pro Script!!!!");
      
                  // Your scripting logic here
              }
      
  2. Now open Vegas and start your script from within Vegas (Tools, Run Script)

  3. Don't close Vegas, you can now change your code and run it again from within Vegas without closing Vegas!

  • But this does not allow for actual debugging the code! So messageboxes dumping outputs will be your friend.....

 

Setting up Debugging - Method 3 (not working)

  1. Start Vegas Pro manually from the Start menu or by double-clicking the executable.

  2. Attach to the Vegas Process:

  3. In Visual Studio, go to "Debug" → "Attach to Process...".

  4. Find vegas220.exe in the list and click "Attach".

  5. Run the Script in Vegas:

    1. From Vegas Pro, run your script manually using the Tools -> Scripting menu.

    2. Visual Studio will hit any breakpoints you set in the script.

  • I could not get this to work either. It just does not stop at my breakpoint. Probably because the dll is not yet loaded and when it is loaded, it is already finished before I can set the breakpoint.

 

So, if anyone knows how to really get debugging to work, would be great! I'll update the text above when I find out how to do it.