Follow-up to Pop-up PDM DataCard C#

I am following up to my question yesterday with some progress. The request is still the same. I wish to have a popup during my file creation (created from a menu command) after the file is created and populated with values from two files. The get and set variables work as well as a popup window, but I can't seem to get the DataCard to show in the window. The examples online all have an existing form already and update that. I am trying to use a form within the class library.

The line view = (IEdmCardView63)destFolder.CreateCardView(fileID, 0, 40, 300, (EdmCallback)this); is incorrect and I want to know how I should be going about doing this. My code is below and works for everything except showing the card.

using System;

using System.IO;

using System.Collections.Generic;

//using System.Linq;

using System.Text;

//using System.Threading.Tasks;

using EdmLib;

using System.Drawing;

using Microsoft.VisualBasic;

using System.Windows.Forms;

namespace ClassLibrary2

{

    public class Class1 : IEdmAddIn5

    {

        public void GetAddInInfo(ref EdmAddInInfo poInfo, IEdmVault5 poVault, IEdmCmdMgr5 poCmdMgr)

        {

            //Specify information to display in the add-in's Properties dialog box  

            poInfo.mbsAddInName = "Menu command sample";

            poInfo.mbsCompany = "SOLIDWORKS Corporation";

            poInfo.mbsDescription = "Adds menu command items";

            poInfo.mlAddInVersion = 1;

            //Specify the minimum required version of SOLIDWORKS Enterprise PDM 

            poInfo.mlRequiredVersionMajor = 10;

            poInfo.mlRequiredVersionMinor = 0;

            //Register a menu command 

            poCmdMgr.AddCmd(100, "Inspection Request (New C#)", (int)EdmMenuFlags.EdmMenu_OnlySingleSelection);

        }

        IEdmCardView63 view;

        public void OnCmd(ref EdmCmd poCmd, ref Array ppoData)

        {

            if (poCmd.meCmdType == EdmCmdType.EdmCmd_Menu) //This makes sure the addin was called on a menu right click 

            {

                if (poCmd.mlCmdID == 100) //This makes sure the menu command ID was 100, which means your addin was the one called 

                {

                    //Let's get moving, it's our turn! 

                    IEdmVault12 myVault = (IEdmVault12)poCmd.mpoVault; //Cast the vault to an Iedmvault12 object for latest functionality 

                    string Mymessage = null;//instantiate a string message 

                    //string StrID = null;//instantiate the ID of the object 

                    if ((((EdmCmdData)ppoData.GetValue(0)).mlObjectID1) != 0) //mlObjectID1 will be 0 if a folder was selected and the ID of the file if a file was selected during a menu command 

                    {

                        //Mymessage = Mymessage + "File: (ID=";

                        IEdmFile5 myfile = (IEdmFile10)myVault.GetObject(EdmObjectType.EdmObject_File, (((EdmCmdData)ppoData.GetValue(0)).mlObjectID1));//Get the file object 

                        string fileNoExt = Path.GetFileNameWithoutExtension(myfile.Name);

                       

                        IEdmEnumeratorVariable10 myvars = default(IEdmEnumeratorVariable10); //Set the enumeratorvariable object 

                        myvars = (IEdmEnumeratorVariable10)myfile.GetEnumeratorVariable(); //Cast the enumeratorvariable object to the file 

                        object CreatedBy = null; //Create a variable to hold the model no. 

                        object Desc1 = null;

                        object Desc2 = null;

                        object Rev = null;

                        myvars.GetVar("CreatedBy", "@", out CreatedBy); //Use the GetVar method 

                        myvars.GetVar("CAD_Description", "@", out Desc1);

                        myvars.GetVar("CAD_Description1", "@", out Desc2);

                        myvars.GetVar("CAD_Revision", "@", out Rev);

                        myvars.CloseFile(false); //Always close the file when done accessing card variables to avoid runtime errors 

                                                 //Mymessage = Mymessage + "File ID: " + myfile.ID + System.Environment.NewLine; //Create a message with the File ID 

                        Mymessage = Mymessage + "CreatedBy: " + CreatedBy + System.Environment.NewLine; //Add the model no. variable 

                        Mymessage = Mymessage + "Description: " + Desc1 + System.Environment.NewLine;

                        Mymessage = Mymessage + "Description1: " + Desc2 + System.Environment.NewLine;

                        Mymessage = Mymessage + "Revision: " + Rev + System.Environment.NewLine;

                        MessageBox.Show(Mymessage); //Show the message box! 

                        MessageBox.Show("Get template path");

                        string templPath = @"C:\\SeanVault\\Templates\\template.item.cvd";

                        string newPath = @"C:\\SeanVault\\Inspection Files";

                        string filename = fileNoExt + " Rev " + Rev.ToString() + ".insp";

                        IEdmFile5 templateFile = default(IEdmFile5);

                        IEdmFolder5 srcFolder = null;

                        templateFile = myVault.GetFileFromPath(templPath, out srcFolder);

                        MessageBox.Show("Get destination path");

                        IEdmFolder5 destFolder = default(IEdmFolder5);

                        destFolder = myVault.GetFolderFromPath(newPath);

                        if (destFolder == null)

                            return;

                        int fileID = 0;

                        fileID = destFolder.CopyFile(templateFile.ID, srcFolder.ID, 0, filename, (int)EdmCopyFlag.EdmCpy_Simple);

                       

                        Interaction.MsgBox("Copied file successfully to new file with ID, " + fileID);

                                                                       

                        IEdmFile5 newFile = default(IEdmFile5);

                        IEdmFile5 itemFile = default(IEdmFile5);

                        newPath = newPath + "\\\\" + filename;

                        //Search for file with .item extension

                        IEdmSearch5 Search = default(IEdmSearch5);

                        Search = (IEdmSearch5)myVault.CreateUtility(EdmUtility.EdmUtil_Search);

                        Search.FindFiles = true;

                        //Search.StartFolderID = 102; //Regular Items ID

                        Search.FileName = fileNoExt + ".item";

                        IEdmSearchResult5 Result = default(IEdmSearchResult5);

                       

                        Result = Search.GetFirstResult();

                        object StockingType = null; //Create a variable to hold the model no.

                        if (Result != null)

                        {

                            MessageBox.Show("Result exists. Begin! Path = " + Result.Path);

                            itemFile = myVault.GetFileFromPath(Result.Path, out srcFolder);

                            IEdmEnumeratorVariable10 itemVars = default(IEdmEnumeratorVariable10); //Set the enumeratorvariable object 

                            itemVars = (IEdmEnumeratorVariable10)itemFile.GetEnumeratorVariable(); //Cast the enumeratorvariable object to the file 

                            //breaks

                            itemVars.GetVar("ITEM_StockingType", "", out StockingType); //Use the GetVar method

                            myvars.CloseFile(false); //Always close the file when done accessing card variables to avoid runtime errors 

                                                     //Mymessage = Mymessage + "File ID: " + myfile.ID + System.Environment.NewLine; //Create a message with the File ID 

                        }

                        newFile = myVault.GetFileFromPath(newPath, out srcFolder);

                        //update variables

                        IEdmEnumeratorVariable10 myNewVars = default(IEdmEnumeratorVariable10); //Set the enumeratorvariable object 

                        myNewVars = (IEdmEnumeratorVariable10)newFile.GetEnumeratorVariable(); //Cast the enumeratorvariable object to the file 

                       

                        myNewVars.SetVar("ITEM_RevisionNumber", "", Rev.ToString());

                        myNewVars.SetVar("ITEM_DescriptionLine1", "", Desc1.ToString());

                        myNewVars.SetVar("ITEM_DescriptionLine2", "", Desc2.ToString());

                        if (StockingType.ToString() != null)

                        {

                            myNewVars.SetVar("ITEM_StockingType", "", StockingType.ToString());

                        }

                        myvars.CloseFile(false); //Always close the file when done accessing card variables to avoid runtime errors 

                                                 //Mymessage = Mymessage + "File ID: " + myfile.ID + System.Environment.NewLine; //Create a message with the File ID 

                        // Create a new instance of the form.

                        Form form1 = new Form();

                        // Create two buttons to use as the accept and cancel buttons.

                        Button button1 = new Button();

                        Button button2 = new Button();

                        // Create the card view interface

                        //BREAKS HERE

                        view = (IEdmCardView63)destFolder.CreateCardView(fileID, 0, 40, 300, (EdmCallback)this);

                        if (view == null)

                        {

                            Interaction.MsgBox("The file does not have a card.");

                            return;

                        }

                        // Set input focus to the first control in the card

                        view.SetFocus(0);

                        // Enable all controls in the card

                        view.Update(EdmCardViewUpdateType.EdmCvut_EnableCtrl);

                        // Get the size needed to display the card

                        int width = 0;

                        int height = 0;

                        view.GetCardSize(out width, out height);

                        // Resize the form window to make room for the card

                        form1.Width = (width + 100);

                        form1.Height = (height + 400);

                        view.ShowWindow(true);

                        //SaveCard.Enabled = false;

                        // Set the text of button1 to "OK".

                        button1.Text = "OK";

                        // Set the position of the button on the form.

                        button1.Location = new Point(10, 10);

                        // Set the text of button2 to "Cancel".

                        button2.Text = "Cancel";

                        // Set the position of the button based on the location of button1.

                        button2.Location

                           = new Point(button1.Left, button1.Height + button1.Top + 10);

                        // Make button1's dialog result OK.

                        button1.DialogResult = DialogResult.OK;

                        // Make button2's dialog result Cancel.

                        button2.DialogResult = DialogResult.Cancel;

                        // Set the caption bar text of the form.  

                        form1.Text = "My Dialog Box";

                        // Define the border style of the form to a dialog box.

                        form1.FormBorderStyle = FormBorderStyle.FixedDialog;

                        // Set the accept button of the form to button1.

                        form1.AcceptButton = button1;

                        // Set the cancel button of the form to button2.

                        form1.CancelButton = button2;

                        // Set the start position of the form to the center of the screen.

                        form1.StartPosition = FormStartPosition.CenterScreen;

                        // Add button1 to the form.

                        form1.Controls.Add(button1);

                        // Add button2 to the form.

                        form1.Controls.Add(button2);

                        // Display the form as a modal dialog box.

                        form1.ShowDialog();

                        // Determine if the OK button was clicked on the dialog box.

                        if (form1.DialogResult == DialogResult.OK)

                        {

                            // Display a message box indicating that the OK button was clicked.

                            MessageBox.Show("The OK button on the form was clicked.");

                            // Optional: Call the Dispose method when you are finished with the dialog box.

                            form1.Dispose();

                        }

                        else

                        {

                            // Display a message box indicating that the Cancel button was clicked.

                            MessageBox.Show("The Cancel button on the form was clicked.");

                            // Optional: Call the Dispose method when you are finished with the dialog box.

                            form1.Dispose();

                        }

                        //Check-in new file

                        newFile.UnlockFile(0,"Created and checked-in with Sean's API.");

                        //myvars.SetVar("CAD_Weight","@", "This Worked");

                        //Mymessage = Mymessage + "File name: " + ((EdmCmdData)ppoData.GetValue(0)).mbsStrData1 + System.Environment.NewLine; //Add the file name 

                    }

                }

            }

        }

    }

}

SolidworksApi macros