MSCE U17 SDK C# Sample Code: how is the *.commands.xml loaded in C# WPF project?

Hi Everybody,

I am trying to understand the sample code comes with the Microstation CONNECT Edition SDK (Update 17). The sample project I am looking at is at

<Mocristation SDK Root Folder>\examples\WPF\WPFDemo\

In this project, there is a file WPFDemo.commands.xml containing the setting of all the command words in Microstation key-in tool, and their corresponding functions to be invoked. However, when I look at the code, I don't understand how this XML file is loaded/compiled in to the compiled DLL. Can you tell me how to understand the structure of this project? or any tutorial that can help me to understand it?

Attached is the sample code project. I was able to run it from Visual Studio 2019 (invoked by "devenv" from Developer Shell), and then load into key-in. I am using Microstation CONNECT Edition update 17.

Thank you!

WPFDemo.zip

Parents
  • Hi Sui,

    at first (I guess it was discussed already), please follow the best practices and use standard subject format to provide common required information like product in short format.

    or any tutorial that can help me to understand it?

    NET SDK examples are tutorials, setup command table in the same way in your project.

    Can you tell me how to understand the structure of this project?

    Command table must comply with these conditions:

    • to be valid xml file
    • its content must be valid command table structure (typically copied from some other project, as Bentley does not provide xsd)
    • must be included in Visual Studio project with correct settings

    <ItemGroup>
        <EmbeddedResource Include="AppCommandTable.xml">
            <LogicalName>CommandTable.xml</LogicalName>
            <SubType>Designer</SubType>
        </EmbeddedResource>
    </ItemGroup>

    I don't understand how this XML file is loaded/compiled in to the compiled DLL.

    It is done automatically:

    When MicroStation is asked to load NET dll:

    • creates .ma loader at background (because MicroStation is not able to load dll directly)
    • searches dll for embedded resources and tries to identify command table
    • when command table (xml file) is found in dll, it is parsed for validity and when everything is fine, it is loaded as command table

    I recommend to use some NET decompiler (free dnSpy, commercial NET Reflector or any other) and look, how compiled functional SDK example assembly looks lie internally.

    Regards,

      Jan

    Answer Verified By: Sui Huang 

  • Hi Jan,

    Thank you for your suggestion. I updated the title of the post to following the standard.

    Inspired by the visual studio project setting you showed, I looked at the property of the command table XML file and find that it is an embedded resource, which means it is included in the compiled DLL file.

    I also changed the file name of the table XML file and the solution still compiles. Then the MS CE mdl utility can still load it and then show the command word in the key-in tool. This indicates that MDL utility does not depend on the file name to read the command table.

    I will try decompiler if there is a need in the future.

    Thank you!

    Sui

Reply
  • Hi Jan,

    Thank you for your suggestion. I updated the title of the post to following the standard.

    Inspired by the visual studio project setting you showed, I looked at the property of the command table XML file and find that it is an embedded resource, which means it is included in the compiled DLL file.

    I also changed the file name of the table XML file and the solution still compiles. Then the MS CE mdl utility can still load it and then show the command word in the key-in tool. This indicates that MDL utility does not depend on the file name to read the command table.

    I will try decompiler if there is a need in the future.

    Thank you!

    Sui

Children
No Data