What is the suggested way for logging an MDL app that is loaded with no MicroStation UI through MS_INITAPPS? I tried the basic Console.WriteLine but nothing ever gets printed on the Windows cmd window. I have some System.Console.WriteLine( ) within the MDL Run method but it never gets printed as I would expect. Below sample code.
[Bentley.MstnPlatformNET.AddIn(ApplicationType = MdlApplicationType.InitApp, MdlTaskID = "SampleClass")] internal sealed class SampleClass : Bentley.MstnPlatformNET.AddIn { private static SampleClass Addin; private Bentley.Interop.MicroStationDGN.Application app; private SampleClass(System.IntPtr mdlDesc) : base(mdlDesc) { // save a reference to addin to prevent it from being garbage collected. Addin = this; } protected override int Run(string[] commandLine) { System.Console.WriteLine("In Run"); app.Visible = false; DesignFile dgn = app.OpenDesignFile("C:\\sample.dgn", true, MsdV7Action.Workmode); System.Console.WriteLine("after open"); switch (this.ApplicationType) { case MdlApplicationType.User: System.Console.WriteLine("User"); break; case MdlApplicationType.DesignApp: System.Console.WriteLine("DesignApp"); break; case MdlApplicationType.InitApp: System.Console.WriteLine("Initapp"); break; } return 0; } }
Here is the Windows cmd I am running:
microstation.exe ustation -WAsampleclass -Debug
And as well, yes, the MDL app is in the Mdlapps folder in MicroStation.
Extract from msdebug.txt, you can see the SampleClass MDL being loaded:
.... Processing macro file [C:\Program Files\Bentley\MicroStation CONNECT Edition\MicroStation\config\appl\pw.cfg] Starting skip to endif, [C:\Program Files\Bentley\MicroStation CONNECT Edition\MicroStation\config\appl\pw.cfg], line 16, depth = 0. if, [C:\Program Files\Bentley\MicroStation CONNECT Edition\MicroStation\config\appl\pw.cfg], line 17, depth = 1. endif, [C:\Program Files\Bentley\MicroStation CONNECT Edition\MicroStation\config\appl\pw.cfg], line 19, depth = 1. endif, [C:\Program Files\Bentley\MicroStation CONNECT Edition\MicroStation\config\appl\pw.cfg], line 23, depth = 0. (Application): PWDIR=HKEY_CURRENT_USER\SOFTWARE\Bentley\ProjectWise\Path [HKEY_CURRENT_USER\SOFTWARE\Bentley\ProjectWise\Path] (Application): PWDIR=C:\Program Files\Bentley\ProjectWise\ [C:\Program Files\Bentley\ProjectWise\] Processing macro file [C:\Program Files\Bentley\ProjectWise\bin\mcm.cfg] Starting skip to endif, [C:\Program Files\Bentley\ProjectWise\bin\mcm.cfg], line 20, depth = 0. if, [C:\Program Files\Bentley\ProjectWise\bin\mcm.cfg], line 23, depth = 1. endif, [C:\Program Files\Bentley\ProjectWise\bin\mcm.cfg], line 27, depth = 1. endif, [C:\Program Files\Bentley\ProjectWise\bin\mcm.cfg], line 28, depth = 0. (Application): _MCM_CFG_=1 [1] (Application): MS_INITAPPS=SampleClass [SampleClass] (Application): MS_INITAPPS=SampleClass [SampleClass] Starting skip to endif, [C:\Program Files\Bentley\ProjectWise\bin\mcm.cfg], line 48, depth = 0. endif, [C:\Program Files\Bentley\ProjectWise\bin\mcm.cfg], line 50, depth = 0. Starting skip to endif, [C:\Program Files\Bentley\ProjectWise\bin\mcm.cfg], line 51, depth = 0. endif, [C:\Program Files\Bentley\ProjectWise\bin\mcm.cfg], line 53, depth = 0. Starting skip to endif, [C:\Program Files\Bentley\ProjectWise\bin\mcm.cfg], line 54, depth = 0. endif, [C:\Program Files\Bentley\ProjectWise\bin\mcm.cfg], line 56, depth = 0. (Application): PW_MDLAPPS_SUBDIR=v1000 [v1000] ...... ...... MS_IMPORTEDIMAGES : System = C:\ProgramData\Bentley\connectsharedcontent\materials\imported\ MS_INCLUDEPARAMETRICDEFMODELS: System = TRUE MS_INITAPPS : System = SampleClass <Locked> MS_INPUT_CONFIGXML : System = C:\Users\<user>\AppData\Local\Bentley\MicroStation\10.0.0\prefs\Personal.inputConfiguration.xml MS_INPUT_CONFIGXMLSEED: System = C:\Program Files\Bentley\MicroStation CONNECT Edition\MicroStation\Default\data\inputConfiguration.xml ...... ......