c1-cms

Installing Static Data Types with Dependencies via Package


I've developed a package that contains two static data types (IClient and IClientHour). One of the static data types (IClientHour) has a dependency on the other static data type (IClient).

I'm attempting to add the data types to my instance of Composite C1 via a package. I would like to leverage the DataTypePackageFragmentInstaller and DataTypePackageFragementUninstaller classes to register and drop my data types with the package.

The problem I'm facing is that the package is failing to validate and spits out the following error:

Failed to build data type descriptor for interface 'Builders.Data.IClientHour' The type 'Builders.Data.IClient' could not be found.

Both types are in a DLL that I am copying to the CMS via the FilePackageFragmentInstaller. In searching the Composite C1 forum I found a suggestion of adding assemblyLoad="true" to the File element for the assembly that contains the types. This suggestion did not solve the issue I'm facing.

Below is a condensed version of my install.xml displaying the sections related to the data types and assembly:

<mi:PackageFragmentInstallers>
      <mi:Add installerType="Composite.Core.PackageSystem.PackageFragmentInstallers.FilePackageFragmentInstaller, Composite" uninstallerType="Composite.Core.PackageSystem.PackageFragmentInstallers.FilePackageFragmentUninstaller, Composite">
          <Files>
              <File sourceFilename="~\Bin\Builders.dll" targetFilename="~\Bin\Builders.dll" allowOverwrite="false" assemblyLoad="true" />
          </Files>
      </mi:Add>

      <mi:Add installerType="Composite.Core.PackageSystem.PackageFragmentInstallers.DataTypePackageFragmentInstaller, Composite" uninstallerType="Composite.Core.PackageSystem.PackageFragmentInstallers.DataTypePackageFragmentUninstaller, Composite">
          <Types>
              <Type name="Builders.Data.IClient, Builders" />
              <Type name="Builders.Data.IClientHour, Builders" />
          </Types>
      </mi:Add>
</mi:PackageFragmentInstallers>

Any assistance/suggestions with accomplishing this task is greatly appreciated.


Solution

  • After asking the same question on CodePlex, wysocki and burningice were able to lead me in the right direction to correct the issue that I was facing.

    In a nutshell, I had used a string to reference the type of my IClient data type from the IClientHour data type. If you use a string you must also include the Assembly name in the reference (e.g. Builders.Data.IClient, Builders).

    As per Composite C1 examples and burningice's guidance you should avoid using a string and instead reference your foreign key using typeof.

    Here is an example of how I orginally tried to reference my data type:

    [ForeignKey("Builders.Data.IClient", AllowCascadeDeletes = true, NullReferenceValue = "{00000000-0000-0000-0000-000000000000}")]

    Here is how I should have referenced it using a string:

    [ForeignKey("Builders.Data.IClient, Builders", AllowCascadeDeletes = true, NullReferenceValue = "{00000000-0000-0000-0000-000000000000}")]

    Per Composite C1 examples and guidance from burningice this is how you should reference another data type (Note: when using this method you must also include the name of the field that you wish to use in the relationship):

    [ForeignKey(typeof(Builders.Data.IClient), "Id", AllowCascadeDeletes = true, NullReferenceValue = "{00000000-0000-0000-0000-000000000000}")]

    References:

    CodePlex Forum Thread: http://compositec1.codeplex.com/discussions/652976

    Composite Documentation: http://docs.composite.net/Console/Static-IData-Types/Example2