DevPartner 2018 Workshop : Maximize Your Traditional Synergy Development with Visual Studio
Exercise 6: Executable Library to .Net Assembly
This is the sixth of a series of exercises that demonstrate the abilities of developing Synergy inside Visual Studio.
If you have not completed the previous exercises you can find the first one here.
This exercise will take our existing code from our object and executable libraries and create a native Windows .NET assembly using Synergy .Net. Throughout the exercise you will make changes to elements of the Visual Studio solution and see the powerful MSBUILD sub-system in action.
To begin the exercise, follow these simple steps:
- Visual Studio should be running and the DevPartner2018 solution opened and active
- From the File menu select Add->New Project…
- In the “Add New Project” dialog locate and expand the Synergy/DE entry and select the Windows entry
- Select the Class Library (.NET Framework) entry
- In the Name entry field type the value OnVinylAssembly
- Click OK
This will create a .NET assembly project. After the project is created it will open up the Class.dbl file. Close this window. We can also delete the default source file from the project:
- In the OnVinylAssembly project locate the Class.dbl source file
- Right-click the Class.dbl file and select Delete
- When prompted select the Delete button
To ensure the correct version of the software is built:
- From the Build menu, select the Configuration Manager… entry
- Against the OnVinylAssembly entry, under the Platform column, check the value is x64. If not:
- Against the OnVinylAssembly entry, under the Platform column change the entry from Any CPU to <New…>
- For the New Platform select x64
- Uncheck the Create new solution platforms checkbox
- Click OK
- Click Close
We already have all the source code we require for this library – it is part of the OnVinylObjectLibrary project. Our goal is to reference the existing source files so as not to make a copy of them. This will ensure that we only have a single copy across multiple projects:
- Ensure that the OnVinylAssembly project is highlighted in the Solution Explorer
- From the Project menu select the Reference Existing Item entry (Please note here this is the “Reference Existing Item” and NOT the “Add Existing Item…” menu entry!
- At this point check that the dialog title includes the project name “OnVinylAssembly”. If it does not, cancel the dialog and reselect the OnVinylAssembly project in the Solution Explorer
- In the “Add Existing Item – OnVinylAssembly” dialog navigate up one folder level and then navigate to the OnVinylObjectLibrary folder
- Highlight and select all the source file with extensions “dbl” and ”dbc”
- Click the Add button
All of our existing source files will be added to the OnVinylAssembly project. If you inspect the properties for any of the included source files, the “Full Path” specification should be the OnVinylObjectLibrary folder.
Now we can try to execute the build process:
- From the Build menu select the Build OnVinylAssembly entry
At this point our OnVinylAssembly project fails to build.
We are missing the same references that our Executable Library requires – the Synergy/DE UI Toolkit. Luckily, Synergex provide a .NET version which we can reference:
- Ensure that the OnVinylAssembly is selected in the Solution Explorer
- From the Project menu select the Add Reference… entry
- At this point check that the dialog title includes the project name “OnVinylAssembly”. If it does not, cancel the dialog and reselect the OnVinylAssembly project in the Solution Explorer
- Select the Assemblies tab
- Select the Extensions folder
- Scroll through the list of assemblies to locate the Synergex.SynergyDE.tklib assembly and place a check in the checkbox next to its name
- Click OK
Now we can try to execute the build process:
- From the Build menu select the ReBuild
At this point our OnVinylAssembly project may still fail to build. The errors this time are data related – it can’t find the repository.
If your project builds this is a result of “environment bleed” which is discussed here. The repository environment variables become part of the solution and not specific to each project. It is recommended that the following step is still completed to ensure that the project continues to build correctly.
Our repository project can be consumed by both Traditional Synergy and Synergy .NET projects:
- Ensure that the OnVinylAssembly is selected in the Solution Explorer
- From the Project menu select the Add Reference… entry
- At this point check that the dialog title includes the project name “OnVinylAssembly”. If it does not, cancel the dialog and reselect the OnVinylAssembly project in the Solution Explorer
- Select the Projects tab
- Check the OnVinylRepository
- Click OK
Now we can try to execute the build process:
- From the Build menu select the Build Solution entry
Again our OnVinylAssembly project may fail to build. If the project does build, this is again because of “project bleed”. Any errors this time are due to the fact that the project can’t find various include files that contain certain application values:
- Ensure that the OnVinylAssembly is selected in the Solution Explorer
- Select the Properties menu entry from the Project menu
- At this point check that the tab page title includes the project name “OnVinylAssembly”. If it does not, close the tab page and reselect the OnVinylAssembly project in the Solution Explorer
- Select the Common Properties tab
- Check the Use common properties checkbox
Now we can try to execute the build process:
- From the Build menu select the Rebuild entry
Success! At this point there is nothing to execute so a successful build means the exercise is complete.