OpenAccess ORM uses VEnhance, which is a special enhancer program, to read and process compiled .NET assemblies for adding persistence capability. You can call VEnhance from the command line, but normally the enhancer is called directly by Visual Studio during build time to process the .NET assemblies in your project.
 |
OpenAccess ORM calls VEnhance as a post-build step for projects whose "Enhancing" property is set to "true". However, if you have specified any post-build events in your visual studio properties, first those events will be called followed by the call to VEnhance.
Therefore, if you have certain post-build steps, such as copying the assembly files to a particular location, the un-enhanced version of the files will be copied. In order to copy the enhanced files, you will need to explicitly call the "VEnhance" command first followed by the "copy" command in the post-build event command line for your project, and then set the "Enhancing" project property to false. |
To build your OpenAccess ORM application, you first compile your .NET source files as you normally do for any application. The next step is to call the VEnhance enhancer tool in order to enhance the assembly files that you have compiled. The following shows a typical command line call to VEnhance:
|
Copy Code |
VEnhance -assembly:AssemblyFileName
|
During the enhancement phase, VEnhance reads the assembly file and uses the information it contains to determine which classes are to be made persistence capable. The file is enhanced "inplace", that is, the enhancement information is written back to the same assembly file that was read.
Command Line Switches for VEnhance
Here is the command line syntax for the VEnhance tool.
|
Copy Code |
VEnhance [options]
-assembly:filename
-config:filename
-debug[+|-]
-verbose[+|-]
-verboseMode:value
-reference:filelist
|
The switches are described below:
|
-assembly |
|
|
Required. ITaskItem[] parameter.
Specifies the assemblies containing [Persistent] classes that need to be enhanced. This switch is mandatory. |
|
-config |
|
|
Optional. ITaskItem[] parameter.
Specifies the application configuration filename (App.config). This parameter is currently ignored. |
|
-debug |
|
|
Optional. Boolean parameter.
The debug mode is used to analyze problems within the VEnhance tool. This mode should only be used if a debugger is attached to VEnhance or if stack-traces from the VEnhance tool are required. Default value is false. |
|
-verbose |
|
|
Optional. Boolean parameter.
Specifies the amount of information to be printed during enhancement and registration. Default value is false. |
|
-verboseMode |
|
|
Optional. Int32 parameter.
The amount of processing information to be printed out during enhancement is specified here by a number. By default it is set to 0. |
|
-reference |
|
|
Required. ITaskItem[] parameter.
This parameter contains a comma separated list of assemblies that are referenced by assembly that is enhanced and is used when the task needs to resolve assembly dependencies. Only assemblies that cannot be found in the global assembly cache must be specified with this switch. Usually assemblies that are passed to the C# compiler with the /reference switch must also be passed to the enhancer. |
Examples
Assume that the persistence capable class Product and some derived classes are compiled to the assembly Products.dll. This is done using the C# compiler.
|
Copy Code |
csc /target:library /out:Products.dll
/reference:OpenAccess.dll Product.cs . . .
|
The OpenAccess ORM enhancer, VEnhance, is then used to add persistence capability for the Product and other persistent classes.
|
Copy Code |
VEnhance -assembly:Products.dll
|
The enhancer reports all persistent classes that have been enhanced.
In a given C# application, the persistence capable class Product is used. The application also uses other persistence capable classes, e.g., Order and OrderItem, which contain references to Product objects. When the application is compiled, the Products assembly is passed as a referenced assembly.
|
Copy Code |
csc /target:exe /out:MyApp.exe
/reference:OpenAccess.dll,Product.dll
Order.cs OrderItem.cs Main.cs
|
The application executable must also be enhanced. The enhancer also needs to load the referenced Products assembly. Therefore, it is passed to the enhancer with the reference switch.
|
Copy Code |
VEnhance -assembly:MyApp.exe -reference:Products.dll
|