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.

Visual Studio Tools for MicroStation

innovoCAD

innovoCAD provides some add-ins or extensions to Microsoft Visual Studio. Those tools make it easy to get started with a Visual Studio project. Visual Studio Tools for MicroStation helps both C++ and .NET developers.

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

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. MDL Code means that you can write a pure MDL that you build using the Bentley tools supplied in \mdl\bin. Native Code means an application built using Microsoft or other tools as a Windows executable binary file, either a .exe or .dll file. …

Microsoft Visual C++ versions matching MicroStation versions
MicroStation Version MDL Code Native Code Comment
10.05.XX.XX 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

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.05.XX.XX 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 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 @ bentley.com) for more information.

Return to MDL articles index.