Struggling with VSTA in VS2022

SilverShaded

Well-known member
Joined
Mar 7, 2020
Messages
110
Programming Experience
10+
Im struggling to make sense of this, I managed to locate what I think are the correct 64bit DLLs and reference them so the 'using' statement is now ok.

However the VSTA.session statement doesnt exist. The code is copied from an old example (VS2015) i was assuming it shouldn't have changed much and can't find an equivalent example for VS 2022. What am I doing wrong?


C#:
using VSTA = Microsoft.VisualStudio.Tools.Applications;

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

        private VSTA.Session _session;

        private void button1_Click(object sender, EventArgs e)
        {
            if (_session == null)
            {
                var sessionMgr = VSTA.SessionManager.Create("MyHostApp");
                _session = sessionMgr.CreateSession();
            }
            _session.Ide.Show();
        }
    }
}
 
Last edited:
Solution
Ok, after isntalling VS2015 and VS2019 i figured it out, it has to be a .Net Framework app for it to work...

To elaborate, when you choose a framework based project, the extensions option appears in the references dialog box and you can select the correct assembly.

Core based projects dont have that option.
What is the error message for line 12

What error message are you getting for line 19?
 
Ok, after isntalling VS2015 and VS2019 i figured it out, it has to be a .Net Framework app for it to work...

To elaborate, when you choose a framework based project, the extensions option appears in the references dialog box and you can select the correct assembly.

Core based projects dont have that option.
 
Last edited:
Solution

Latest posts

Back
Top Bottom