Bentley Technology Partner

MicroStation® is a 3D design tool and application platform, developed, sold and supported by Bentley Systems, Inc.. Here are answers to questions about MicroStation application development and Microsoft Visual Studio. when implementing functionality in a DLL written using Visual Studio. The questions are posted by C#, C++ and MDL developers on the Bentley Discussion Groups.

Q Hints about implementing an application for MicroStation using Microsoft Visual Studio™.

Windows: Short File Paths and MS Environment Variable

Windows: Short File Paths

Not all parts of the SDK are happy with Windows long file paths. Familiarise yourself with short file paths, also known as 8.3 paths.

Windows Environment Variable MS

You may find it useful to define Windows environment variable MS. Some parts of the SDK use MS to find the MicroStation folder, its DLLs and .NET assemblies.

It's best to define MS using a DOS-style path (short file path). Here's an example …


Visual Studio Versions

Q Which version of Microsoft Visual Studio™ should I use to develop my C++ MicroStation application?

A The table below shows MicroStation versions and recommended versions of Visual Studio for C++ development. Native Code means an application built using Microsoft or other tools as a Windows executable binary file, either a .exe or .dll file. A MicroStation app. is usually implemented in a DLL.

Microsoft Visual C++ versions matching MicroStation versions
MicroStation Version MDL Code Native Code Comment
10.12.XX.XX and later N Visual Studio 2017 (Visual C++ 17) 64-bit
10.05.XX.XX and later N Visual Studio 2015 (Visual C++ 14) 64-bit
10.04.XX.XX N Visual Studio 2013 (Visual C++ 12) 64-bit
08.11.XX.XX Y Visual Studio 2005 (Visual C++ 8) 32-bit, Service Pack 1
08.09.XX.XX Y Visual Studio 2003 (Visual C++ 7.1)
08.05.XX.XX Y Visual C/C++ 6.0

Visual Studio Pro, Enterprise or Community Edition?

It's always safe to use Visual Studio Pro or Visual Studio Enterprise (depending on the depth of your pocket). More recently, Microsoft have introduced Visual Studio Community Edition. Visual Studio Community Edition seems to work well when building an app. for MicroStation CONNECT. Visual Studio Community Edition is currently cost-free for a small number of developers, but read Microsoft's license conditions!

Byte Code or Native?

MicroStation V8i lets you build an app. using the MDL (MicroStation Development Library) C implementation. MDL Code means that you can write a pure MDL for MicroStation that you build using the Bentley tools supplied in \mdl\bin. MDL is not available with MicroStation CONNECT: use C++ or .NET to build your app.

See this FAQ from Bentley Systems.

Q Which version of Microsoft Visual Studio™ should I use to develop my .NET MicroStation application?

A The table below shows MicroStation versions and recommended versions of Visual Studio for .NET development …

Microsoft Visual Studio versions matching MicroStation versions
MicroStation Version Managed Code (.NET) Delivered CLR Recommended CLR
10.14.XX.XX and later Visual Studio 2017 or later .NET runtime V4.6 .NET runtime V4.6.2
10.12.XX.XX and later Visual Studio 2015 or later .NET runtime V4.6 .NET runtime V4.6.1
10.05.XX.XX and later Visual Studio 2013 or later .NET runtime V4.5.2 .NET runtime V4.6.1
10.04.XX.XX Visual Studio 2013 .NET runtime V4.5.1
08.11.XX.XX Visual Studio 2005 or later .NET runtime V3.5
08.09.XX.XX Visual Studio 2005 or later .NET runtime V3.0
08.05.XX.XX N/A N/A

When you install Visual Studio the .NET framework is installed also. In the table above, column Delivered CLR shows the framework version delivered with the product. Microsoft sometimes updates the .NET framework independently of Visual Studio. Column Recommended CLR shows the version of the .NET framework that you should install for compatibility with the corresponding version of MicroStation.

For example, MicroStation CONNECT v10.04 requires Visual Studio 2013, which delivers the .NET CLR v4.5.1. MicroStation CONNECT v10.05 requires Visual Studio 2015, which delivers the .NET CLR v4.5.2 but you should install the later version v4.6.1.

You can obtain the .NET framework from Microsoft.

Q What version of Visual C++ does Bentley Systems use to build MicroStation?

A The answer depends on the version of MicroStation.

MicroStation CONNECT

Bentley Systems build MicroStation V10.05 and later with the C++ tools provided by Visual Studio 2015 (Visual C++ 14). Earlier versions of MicroStation V10 used Visual Studio 2013. Note that this is a 64-bit version of MicroStation and requires a 64-bit operating system and a 64-bit toolset.

MicroStation V8i

Bentley Systems build MicroStation V8i with the C++ tools provided by Visual Studio 2005. That's Visual C++ v8. Earlier versions of MicroStation were built with earlier versions of the Microsoft tools. See the table above for details.

Using a Different Version of the Build Tools

If you use a different version of Visual Studio, then you are using a different version of Visual C++. Your code probably compiles successfully, but you get linkage errors. Linkage errors may occur in a debug build, a release build, or both types of build.

Why do those linkage errors occur? For one or more of several reasons. Different versions of a compiler may …

  1. Lay out data in different ways
  2. Have different rules on data alignment
  3. Place data in different areas of the operating system's memory space
  4. Implement a different version of the C++ standard

The linker attempts to align one set of data (from your compiler) with the data in the MicroStation DLLs created by Visual C++ v8. When the compiler rules about data layout differ between two versions, then the linker cannot reconcile them and you will see error messages. Note that those errors are not compiler errors but linker errors.

When building an application using Microsoft Visual C++, the build errors are classified; compiler errors are prefixed with 'C' and linker errors with 'L'.

WString Example

Here's an example that illustrates the problem of using different versions of Visual C++. Bentley::WString (henceforth simply WString) is a simple string class that inherits from std::basic_string (#include <WString.h>). std::basic_string, as you probably know, is a C++ template class, and so therefore is WString.

WString specialises the standard library's string class to work with certain MDL data types. There's nothing out of the ordinary — WString is a humdrum string class that's increasingly used with the MicroStationAPI C++ interface.

Why is it, then, that when you attempt to build an application with Visual C++ V9 (supplied by Visual Studio 2008) or later, MicroStation crashes at run-time? You may see an incomprehensible error message similar to this …

0: Void std._Container_base12._Orphan_all(std._Container_base12*)
1: Void std._String_val<wchar_t,Bentley::Memory::MemutilAllocator<wchar_t> >.{dtor}(std._String_val<wchar_t\,Bentley::Memory::MemutilAllocator<wchar_t> >*)
c:\program files\microsoft visual studio 10.0\vc\include\xstring(479)
2: Void std.basic_string<wchar_t,std::char_traits<wchar_t>,Bentley::Memory::MemutilAllocator<wchar_t> >.{dtor}(std.basic_string<wchar_t\,std::char_traits<wchar_t>\,Bentley::Memory::MemutilAllocator<wchar_t> >*)
c:\program files\microsoft visual studio 10.0\vc\include\xstring(755)
3: Void Bentley.WString.{dtor}(Bentley.WString*)

The reason is that MicroStation, and hence WString, was built with Visual C++ V8. Here, the developer is attempting to use Visual C++ V10. The two versions may lay data out in different ways, or perhaps use different memory allocation algorithms. Whatever the reason, there are two incompatible versions of WString.

Moral:  use the same version of C++ as is used to build MicroStation.

Contact Bentley Systems or the BDN (bdn @ for more information.

Return to MDL articles index.