MicroStation CONNECT Visual Studio Extensions (VS2017)

Manual installation process description

MicroStation SDK Visual Studio project templates are provided as zip files containing sample project files. Such templates can be installed by copying the zip files into the template folder of the Visual Studio installation.


By default the project folder for Visual Studio projects is:
"%userprofile%\Documents\Visual Studio 2017\Templates\ProjectTemplates"

<language> can be of a different programming language name like “Visual C++ Project” or “Visual C#”

To verify for your Visual Studio 2017 installation the configured location for project templates in the VS menu select “Tools” > “Options”. In this "Options" dialog scroll left down to "Projects and Solution" > "Locations.
This will show a dialog similar to this:

Browse to the folder configured with "User project templates location:"  

This folder should list the two following folder:

Visual C#
Visual C++ Project

These two folder are the target folder to copy the extracted folder into from the TemplatesToUseForVS2017.zip

Use of the MicroStation CONNECT Edition templates in Visual Studio 2017

After copying the zip files the templates are immediately ready to use and new projects can be created.
In Visual Studio select “New Project” and  under Templates you will find in C# and C++ new entries:

For C#:

And for C++:

Here selected a “Sample” C# project. Select the name and location and hit OK to create the new VS c# project. With creating the new project it is also opened and in the VS “Solution Explorer” the new created parts of the project are listed.

 This project includes one .cs file with the code required to be executed within MS as Addin, it is a typical “Hello World” project:

//--------------------------------------------------------------------------------------+
//
//    $Source: Sample1.cs $
// 
//    $Copyright: (c) 2019 Bentley Systems, Incorporated. All rights reserved. $
//
//---------------------------------------------------------------------------------------+

//---------------------------------------------------------------------------------------+
//	Using Directives
//---------------------------------------------------------------------------------------+
using System.Windows.Forms;

namespace Sample1
{
    internal sealed class Sample1 : Bentley.MstnPlatformNET.AddIn
    {
        //--------------------------------------------------------------------------------------
        // @description   This function does...
        // @bsimethod                                                    Bentley
        //+---------------+---------------+---------------+---------------+---------------+------
        private Sample1(System.IntPtr mdlDesc) : base(mdlDesc)
        {
        }

        //--------------------------------------------------------------------------------------
        // @description   This function does...
        // @bsimethod                                                    Bentley
        //+---------------+---------------+---------------+---------------+---------------+------
        protected override int Run(string[] commandLine)
        {
            MessageBox.Show("Hello World");
            return 0;
        }
    }
}

Use Build >  Build Solution to create Addin (.dll).

The output of the building process should look similar to this:

1>------ Build started: Project: Sample1, Configuration: Debug x64 ------
1> Sample1 -> D:\Data\installs\MS10130101\MicroStation\Mdlapps\Sample1.dll
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

To verify the correctness of the created Addin start MS CONNECT Edition and open any DGN file.

Use the keyin “mdl load” to open the dialog box to launch applications. Such a dialog:

Click on Browse and navigate to the ..\MicroStation\mdlapps folder if not already displayed:

By default all .ma applications are listed to load. Change the filter to All files (*.*) to locate also the Addin .dll files and select the previous created sample1.dll and click on “Open”:

This Addin is now loaded and the function Run executed. The dialog to show the text “Hello World” opens:

This is the confirmation, that the Addin was created and executed successfully.

Related
Recommended