Calling External Code and Using Statements

When calling code from an external DLL, you will need to use the full namespace of the functions that you want to use.

You can also define Using statements for your project. To add a Using statement, click on the drop-down indicator and type in the drop-down box.

While not necessary, they help simplify the process of specifying namespaces. For example, if your script references certain DLLs, like a VisionPro DLL (e.g. Cognex.VisionPro.Core.dll), by specifying Using statements for the namespace (e.g. Cognex.VisionPro and/or Cognex.VisionPro.PMAlign), you can use types from these namespaces with their "short" name (e.g. if you wanted to create a new PMAlign pattern object, using CogPMAlignPattern pattern = new CogPMAlignPattern();).

However, if you do not provide a Using statement for the CognexPMAlignPattern namespace, the "short" name code (CogPMAlignPattern pattern = new CogPMAlignPattern();) will not compile. You would have to use the "full" name, i.e. namespace + class name (e.g. Cognex.VisionPro.PMAlign.CogPMAlignPattern pattern = new Cognex.VisionPro.PMAlign.CogPMAlignPattern();).