Specific Form from cs (VisualBasic)

taurojo wrote on 8/14/2017, 1:39 PM

Hi,


I'm sorry for my English.
I have a dll create in Vegas Studio whit two Forms. Form1 and Form2 in the same dll
I like to create a script cues. To call a specific form in the dll. One script to one form and another for the other Form
But I have a problem with object Vegas. The same error forever, null object!! 

How can I work with the vegas object to get the data?

And not error in Visual Studio

Thanks for your time!!!


Visual Basic Form1

using ScriptPortal.Vegas;
using System;
using System.Windows.Forms;

namespace TESTEVARIOSFORMS
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        private void Form1_Load(object sender, EventArgs e)
        {

// ERROR NULL OBJECT!!!
           label1.Text=  EntryPoint.myVegas.Version.ToString();

        }
    }

public class EntryPoint
    {

      
        public static Vegas myVegas;

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

        }
    }





}


And my cs:

using ScriptPortal.Vegas;
using System.Windows.Forms;
using TESTEVARIOSFORMS;


 
public class EntryPoint
{
            
            
            
    

        public static Vegas myVegas;

            public void FromVegas(Vegas vegas)
            {            
                myVegas = vegas;
                Form1 miForm = new Form1();
                miForm.Show();
            }
    
}

 

XML:

<?xml version="1.0" encoding="UTF-8" ?> <ScriptSettings>     <AssemblyReference >C:\Users\adelpino\Documents\Visual Studio 2017\Projects\TESTEVARIOSFORMS\TESTEVARIOSFORMS\bin\Debug\TESTEVARIOSFORMS.dll</AssemblyReference>   </ScriptSettings>

 

 

 

 

 

 

Comments

jetdv wrote on 8/15/2017, 9:18 AM

What if you change this line:

Form1 miForm = new Form1();

to

Form1 miForm = new Form1(myVegas);

 

Then change this line:

private void Form1_Load(object sender, EventArgs e)
 

to:

private void Form1_Load(Vegas myVegas)

 

and then this line:

label1.Text=  EntryPoint.myVegas.Version.ToString();
 

to

label1.Text= myVegas.Version.ToString();
 

taurojo wrote on 8/15/2017, 12:20 PM

😅

Sorry but:

  Form1 miForm = new Form1(myVegas);

 

Not work for me.

'TESTEVARIOSFORMS.Form1' does not contain a constructor that takes 1 arguments

jetdv wrote on 8/15/2017, 12:52 PM

Sorry, change:

        public Form1()
        {
            InitializeComponent();
        }
 

to:

private Vegas myVegas = null;

        public Form1(Vegas vegas)
        {

myVegas = vegas;
            InitializeComponent();

label1.Text= myVegas.Version.ToString();
        }

 

I've never needed a "Form_Load". You should be able to remove:

        private void Form1_Load(object sender, EventArgs e)
        {

// ERROR NULL OBJECT!!!
           label1.Text=  EntryPoint.myVegas.Version.ToString();

        }
 

taurojo wrote on 8/15/2017, 6:28 PM

 

Sorry but it does not work for me.

You can publish an full example, please!!

. I am looking for a file that opens a specific "Form" inside the dll that I created in Visual Studio(c#). It always gives me the same Null object error.

 

I can directly open my dll and within my dll a call to a Form1 or Form2.

But I do not want to create a dll for each created Form.

 

I'm desperate.

 

How can I pass the Vegas object to the dll. I have no problem launching a specific form from file .cs, but when I try to rescue data( label1.Text=  EntryPoint.myVegas.Version.ToString(); ). I can not, NULL OBJECT ERROR .

 

Thanks for your time.

 

jetdv wrote on 8/16/2017, 9:53 AM

Save this as a .cs (such as TestForm.cs) file and it will run using Tools - Scripting - Run Script and select that .cs file.

using System;
using System.Drawing;
using System.IO;
using ScriptPortal.Vegas;

namespace Test
{
    public class TestForm : System.Windows.Forms.Form
    {
        private Vegas myvegas;
        private System.Windows.Forms.Label label1;
        public TestForm(Vegas vegas)
        {
            InitializeComponent();
            myvegas = vegas;
            label1.Text = myvegas.Version.ToString();
        }

        #region Windows Form Designer generated code
        ///
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
             this.label1 = new System.Windows.Forms.Label();
             this.SuspendLayout();
             //
             // label1
             //
             this.label1.Location = new System.Drawing.Point(16, 16);
             this.label1.Name = "label1";
             this.label1.Size = new System.Drawing.Size(200, 16);
             this.label1.TabIndex = 0;
             this.label1.Text = "";
             //
             // TestForm
             //
             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
             this.ClientSize = new System.Drawing.Size(664, 302);
             this.Controls.Add(this.label1);
             this.MaximizeBox = false;
             this.MinimizeBox = false;
             this.Name = "TestForm";
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
             this.Text = "Test Form";
             this.ResumeLayout(false);
        }
       #endregion
    }
}
public class EntryPoint
{
   private static Test.TestForm form;

   public void FromVegas (Vegas vegas)
   {
      form = new Test.TestForm(vegas);
	form.ShowDialog();
   }
}

 

 

 

jetdv wrote on 8/17/2017, 9:17 AM

Did that help you get it working?