Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Remove PostSharp reference and, if present, the file RequiresPostSharp.cs from the project (selected items in figure above).
  2. Open packages.config and remove the reference to PostSharp. The exact syntax will depend on the version of the .NET framework you are working with, and the corresponding version of PostSharp available at the moment of following this tutorial. So the reference could be, for example:
    <package id="PostSharp" version="2.1.7.28" targetFramework="net40" />
    or
    <package id="PostSharp" version="3.1.75" targetFramework="net452" />
  3. Remove all other references to PostSharp in the project:
    1. Unload the project (right click on project - Unload project)
    2. Edit project file (right click on project - Edit DeltaShell.Plugins.VolumeModel.csproj)
    3. Remove (near the end of the csproj) all references to PostSharp. For example:

      Code Block
      languagec#
      <Import Project="..\packages\PostSharp.2.1.7.28\tools\PostSharp.targets" Condition="Exists('..\packages\PostSharp.2.1.7.28\tools\PostSharp.targets')" />


      or

      Code Block
      languagec#
      <DontImportPostSharp>True</DontImportPostSharp>
      
      ...
      
      <Import Project="..\packages\PostSharp.3.1.75\tools\PostSharp.targets" Condition="Exists('..\packages\PostSharp.3.1.75\tools\PostSharp.targets')" />
        <Target Name="EnsurePostSharpImported" BeforeTargets="BeforeBuild" Condition="'$(PostSharp30Imported)' == ''">
          <Error Condition="!Exists('..\packages\PostSharp.3.1.75\tools\PostSharp.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://www.postsharp.net/links/nuget-restore." />
          <Error Condition="Exists('..\packages\PostSharp.3.1.75\tools\PostSharp.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://www.postsharp.net/links/nuget-restore." />
        </Target>


      The exact lines to be removed will depend on the version of Visual Studio being used, and on the version of PostSharp that was incorporated to the project.

    4. Finally, load project back again.

Set startup project

Start The code being written during this tutorial cannot be directly invoked as start up program. The GUI of Delta Shell must be assigned as the start up executable file. This will on its turn call all plug ins in the framework, as well as the one we are developing in this tutorial. In order to change this setting, start by building the project. This action will copy DeltaShell to the bin folder next to your solution file (for example, D:\VolumeModel\bin)
Now open the project properties, and go to the debug page and to change set the startup program to : the location of the executable file for the GUi of Delta Shell, for example D:\VolumeModel\bin\Debug\DeltaShell\DeltaShell.Gui.exe.

 

Select the radio button Start external program, and indicate the path to the executable file for the GUI of Delta Shell in the corresponding field.

Image AddedImage Removed

Create an application plugin class

Add a new class named VolumeModelApplicationPlugin to the project and add , using the following code describing in that file to describe the application part of the plugin:

Code Block
using DelftTools.Shell.Core;
using Mono.Addins;

namespace DeltaShell.Plugins.VolumeModel
{
    [Extension(typeof(IPlugin))]
    public class VolumeModelApplicationPlugin : ApplicationPlugin
    {
        public override string Name
        {
            get { return "VolumeModelApplication"; }
        }
        public override string DisplayName
        {
            get { return "Volume model application"; }
        }
        public override string Description
        {
            get { return "Application plugin of the volume model application"; }
        }
        public override string Version
        {
            get { return "1.0"; }
        }
        public override string FileFormatVersion
        {
            get { return "1.0"; }
        }
    }
}

...

Create a GUI plugin class

Create Now, create a new class named called VolumeModelGuiPlugin to the project and add the following code describing Gui part of the plugin:

...

To get the code above to work, we still need to add a reference to DelftTools.Shell.Gui in the project.

...

The dll referred to can be found in inside the folder packages of the project. The exact location will depend on your system:

 

Note
titleSet local copy of reference to False

Important: Once the reference has been added, it will be shown in the list of references in the solution explorer. Select this item, and set the Copy Local property of the DelftTools.Shell.Gui reference to False. The DeltaShell framework will have already copied it to the bin, so we do not need to copy the DelftTools.Shell.Gui.dll to our plugin folder.

Exercise results

Run You should now be able to build the solution, and start up Delta Shell from Visual Studio. Once the application is up and running, open the Plugins window (File | Plugins ). Check that both the Volume model application plugin and the Volume model application (UI) plugin are visible in the overview of loaded plugins:

...