Up | .Net 1.1 with Scorpion | Converting Scorpion .Net 1.1 to 2.0

 

  

 
Converting Scorpion .Net 1.1 to 2.0
This section provides a guideline to convert Scorpion .Net 1.1 script to .Net 2.0 and a brief description of the basic syntax changes.


When moving a .Net 1.1 script to .Net 2.0 the following steps must be done:


1. Support both Py24 / Net1.1 and Py26 / .Net 2.0 - replace import CLR

try:
  import CLR # Import CLR for .Net 1.1
except:
  import clr as CLR # Import CLR for .Net 2.0
import CLR.System
print ".Net version:", CLR.System.Environment.Version

2. Change Font Construction

.Net 1.1 Version

import CLR
from CLR.System.Drawing import Font, FontStyle
self.TaskLabel1.Font = Font("Microsoft Sans Serif", 21.75 , FontStyle.Bold)

.Net 2.0 Version

import clr
from System.Drawing import Font, FontStyle, GraphicsUnit
self.TaskLabel1.Font = Font("Microsoft Sans Serif", 21.75 , FontStyle.Bold, GraphicsUnit.Point)

3. Hint - Exit Code Exception

If you receive unhandled exceptions on Scorpion exit add code to Central Stop to stop event solvers:

# manualy call application domain shutdown
import clr
import System
tp = System.Type.GetType('Microsoft.Win32.SystemEvents, System, Version=2.0.0.0, Culture=neutral, PublicKyToken=b77a5c561934e089')
mi = tp.GetMethod('Shutdown', System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static, None, [], [])
mi.Invoke(None, [])


Changes from .Net 1.1 to .Net 2.0

This section describes the syntax change from .Net 1.1 to .Net 2.0


1. The CLR. qualified import is removed - Replace CLR. prefix with an empty "" string

The easiest way to do this is to use the text editor replace.

2. Rename Import CLR to clr

.Net 1.1 Sample

import CLR
import CLR.System.Windows.Forms as WinForms
from CLR.System.Drawing import Size, Point, ContentAlignment, Font, Color
from CLR.System import Int32, Decimal

.Net 2.0 Sample  - IronPythonCompatible

import clr
import System.Windows.Forms as WinForms
from System.Drawing import Size, Point, ContentAlignment, Font, Color
from System import Int32, Decimal






 
 

Scorpion Vision Version XII : Build 646 - Date: 20170225
Scorpion Vision Software® is a registered trademark of Tordivel AS.
Copyright © 2000 - 2017 Tordivel AS.