10.2.2.3   Limitations and Troubleshooting

Besides the restrictions mentioned in this section and in section “General Aspects of Code Generation”, please also check the description of the HDevelop operators in section “Menu 算子.

Variable Names

The export adds the prefix ho_ to all local iconic and hv_ to all local control variables, respectively, to avoid collisions with reserved words.

Exception Handling

In HDevelop, every exception normally causes the program to stop and report an error message in a dialog window. This might not be useful in C#. The standard way to handle this in C# is by using the try-catch mechanism. This allows you to access the reason for the exception and to continue accordingly. For HDevelop programs containing error handling using dev_set_check('~give_error') (or set_check('~give_error')), the corresponding code is automatically included. Every operator call, for which it is assumed that the HALCON error mechanism is turned off, is enclosed in a try block followed by a catch block. The latter handles the exception and assigns the corresponding HALCON error number to the error variable activated by dev_error_var or to a local error variable otherwise.

Please note that a call of dev_set_check('~give_error') has no influence on the operator call. The exception will always be raised. This is also true for messages like H_MSG_FAIL, which are not handled as exceptions in C++, for example.

内存管理

The .NET Framework's runtime environment CLR (Common Language Runtime) has a mechanism called garbage collector, which is used by the CLR to remove no longer needed .NET objects from memory. As mentioned earlier, in the exported C# code every iconic object is represented by a .NET HObject object. From the garbage collector's point of view, a .NET HObject object is rather small. Thus, it might not be collected from memory although the underlying iconic object (for example, an image) might in fact occupy a large portion of memory. To avoid memory leaks caused by this effect, in the exported code every iconic object is disposed explicitly before it is assigned a new value.