Changes between Version 26 and Version 27 of CodeBestPractices


Ignore:
Timestamp:
2012-12-01 11:34:02 (7 years ago)
Author:
jeroens
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CodeBestPractices

    v26 v27  
    9393== Compatibility == 
    9494 
     95We want EwE to run on any operating system, and any processor memory model. This section provides some practical tips to keep EwE Operating System-neutral. 
     96 
    9597=== Mono === 
    9698 
    97 .NET is in theory system-independent, and .NET applications can be deployed under Unix, Linux, MacOS, etc using runtime environments such as [http://www.mono-project.com/Main_Page Mono]. However, not all .NET features work under Mono, most notably the Microsoft.!VisualBasic assembly. This can prove problematic since every Visual Basic project by default receives a reference to this assembly. 
     99.NET is in theory system-independent, and .NET applications can be deployed under Unix, Linux, MacOS, etc using runtime environments such as [http://www.mono-project.com/Main_Page Mono]. However, not all .NET features work under Mono, most notably the Microsoft.!VisualBasic assembly. When you start a new project in Visual Studio, it is immediately provided with a reference to this assembly. Aargh. You will have to take that away: 
    98100 
    99 In EwE we have worked around this problem by redefining key types and constants from the Microsoft.!VisualBasic assembly in [http://webservice.ecopath.org/Ecopath/Help/Index.aspx EwEUtils]. You should not use Chr, Asc, IIF, !TriState, !MsgBox, UBound, !InStr, vbTab, vbCrLF and a whole whack of other old and familiar constructs if you wish your application to run on any other OS than Windows. 
     101 * Right-click your project in the Solution Explorer and select 'Properties' 
     102 * In the References tab, clear the check beside Microsoft.VisualBasic in the 'Imported Namespaces' 
     103 
     104Done. 
     105 
     106Now, your code may require some of the handy-dandy bits that this assembly provided. We redefined some of the key types and constants from the Microsoft.!VisualBasic assembly in [http://webservice.ecopath.org/Ecopath/Help/Index.aspx EwEUtils]. We did not copy all of 'em, some good .NET equivalents exist for outdated VB6-derived contraptions such as string manipulation functions and file interactions. You should not use Chr, Asc, IIF, !TriState, !MsgBox, UBound, !InStr, vbTab, vbCrLF and a whole whack of other old and familiar constructs if you wish your application to run on any other OS than Windows. 
    100107 
    101108To remove reliance on Microsoft.!VisualBasic simply remove the auto-generated reference in the project properties References page. For most constructs .NET offers a solid alternative (for instance Array.!GetUpperBound()), but for other constructs you may have to be creative (vcTab becomes Convert.!ToChar(9).!ToString() - or do you have a better idea?).