Share via


How to: Create an SDM Resource

How to: Create an SDM Resource

This topic describes how to create two SDM resource definitions: a certificate resource, and a certificate store resource that hosts the certificate resource.

In SDM, each kind of object (system, resource, or endpoint) has certain characteristics that serve as guidelines in deciding which to choose when modeling. For example, systems represent stand-alone solutions that can be independently deployed.

Resources are effective when:

  • The object you are modeling may be reused in many different configurations.
  • The object you are modeling is not a solution by itself but only useful in conjunction with other objects.
  • The object you are modeling does not enter into communication relationships with other objects.

A certificate object and a certificate store object both fit all the above criteria.

The following procedure shows how to go about creating two resource definitions: a certificate resource, and a certificate store resource that hosts the certificate resource.

Bb167812.wedge(en-us,VS.90).gifTo create an SDM resource

  1. Create a .sdm file.

    Use the following XML code to create a file called Microsoft.Samples.Certificates.sdm. The <Information> element is optional and provides details about the owner and the contents of the document.

    [XML]

    <SystemDefinitionModel 
    

Name="Microsoft.Samples.Certificates" Version="1.0.0.0" DocumentLanguage="en" xmlns="https://schemas.microsoft.com/SystemDefinitionModel/2005/1"> <Information> <FriendlyName>Sample certificate model</FriendlyName> <CompanyName>Microsoft Corporation</CompanyName> <Copyright>Copyright ) Microsoft Corporation.
All rights reserved.
This is provided AS IS with no warranties, and confers no rights. </Copyright> <Description>SDM model for certificate resources</Description> </Information> <!-- Imports --> <!-- Setting Definitions --> <!-- Resource Definitions --> <!-- Relationship Definitions --> <!-- Hosting Definitions --> <!-- Manager -->

</SystemDefinitionModel>

  1. Add the XML for two resource definitions: X509Certificate and CertificateStore.

    Two elements must be added to a .sdm file to create a resource: <ResourceDefinition> and <ContainmentDefinition> element.

    The following XML code defines the certificate resource and a certificate store resource.

    [XML]

    <!--
    

Resource Definitions --> <ResourceDefinition Name="CertificateStore" Layer="ApplicationHost" Abstract="true"/> <ResourceDefinition Name="X509Certificate" Layer="Application" Abstract="true"/>

  1. Reference a definition from another document using the <Import> element.

    When an <Import> element is used in the .sdm file, the compiler command sdmc.exe /r must be used to compile the document. Each <Import> element specifies:

    • A reference to a definition in another SDM document.
    • An Alias attribute whose value specifies the prefix that will be used when referring to other documents from the current document.
    • The Name attribute of the SystemDefinitionModel being referenced.

    Add the following XML code to the Microsoft.Samples.Certificates.sdm file to specify the imports to be used in this sample.

    [XML]

        <!--
    Imports
    -->
    
    <Import Alias="WindowsHost" Name="Microsoft.WindowsHost" />
    <Import Alias="WindowsApp" Name="Microsoft.WindowsApplication" />
    <Import Alias="IIS" Name="Microsoft.InternetInformationServices" />
    <Import Alias="WebHost" Name="Microsoft.WebHost" />
    <Import Alias="WebApp" Name="Microsoft.WebApplication" />
    <Import Alias="Constraints" Name="System.Constraints" />
  2. Compile the .sdm document using the SdmC.exe tool with the /SearchPath argument to tell the compiler where to find the referenced built-in SDM documents that are not in the current directory.

    The environment variable SdmModelsDir has already been set by the SDM Command Prompt window to point to the directory where the referenced documents are installed.

    SdmC.exe Microsoft.Samples.Certificates.sdm /Output Microsoft.Samples.Certificates.sdmdocument /Reference Microsoft.Configuration.sdmdocument /r Microsoft.Data.sdmdocument /r Microsoft.DistributedApplication.sdmdocument /r Microsoft.FileSystem.sdmdocument /r Microsoft.InternetInformationServices.sdmdocument /r Microsoft.OperatingSystem.sdmdocument /r Microsoft.WindowsApplication.sdmdocument /r Microsoft.WindowsHost.sdmdocument /r Microsoft.Web.sdmdocument /r Microsoft.WebHost.sdmdocument /r Microsoft.WebApplication.sdmdocument /r System.Constraints.sdmdocument /r System.Flow.sdmdocument /SearchPath "%SdmModelsDir%\"

    Since the .sdm document is valid, the command above will produce the compiled form of the document, namely, Microsoft.Samples.Certificates.sdmdocument. Note that the format of the compiled file is slightly different from the format of the .sdm file.

  3. Create the containment relationships.

    A containment relationship is specified between a system and each of the resources that it can contain. To enable the addition of a resource to a system in the designer, a containment relation must exist between the system and the resource. You want a certificate to be contained by two systems, namely WindowsApplication and WebApplication (also called ASP.NETWebApplication in Application Designer). Both of these systems are defined in other SDM documents. Note that they were explicitly imported in the previous step. A containment definition must be specified for each containment relationship. There are three required attributes for a containment:

    • A Name attribute that must be unique across the SDM document.
    • A ParentDefinition attribute that contains the name of the system that will contain the resource. In this case, WindowsApplication and WebApplication respectively, for the two relationships.
    • A MemberDefinition attribute which is the name of the resource, namely, X509Certificate.

    Add the XML code that specifies the two containment relationships for a certificate to the SDM document.

    [XML]

        <!--
    Relationship Definitions
    -->
    <!--
    Certificate containment relationships
    -->
    
    <!--
    A WindowsApplication and WebApplication can contain a certificate.
    -->
    <ContainmentDefinition Name="WindowsApplicationContainsCertificate" 
     ParentDefinition="WindowsApp:WindowsApplication" 
     MemberDefinition="X509Certificate"/>
    
    <ContainmentDefinition Name="WebApplicationContainsCertificate" 
     ParentDefinition="WebApp:WebApplication" 
     MemberDefinition="X509Certificate"/>

    Next, add the relationships for the certificate store resource. You will specify a containment relationship between a certificate store and WindowsHost and between a certificate store and WebServer. These are two systems on the host layer that host the WindowsApplication and WebApplication systems. Like the two application layer systems, these two host layer systems are defined in other SDM documents. Note that their definitions were also explicitly imported in the previous step. Add the following XML code to specify these containment relationships.

    <!--
    Certificate store containment relationships
    -->
    <ContainmentDefinition Name="WindowsHostContainsCertificateStore" 
     ParentDefinition="WindowsHost:WindowsHost" 
     MemberDefinition="CertificateStore"/>
    
    <ContainmentDefinition Name="WebServerContainsCertificateStore" 
     ParentDefinition="WebHost:WebServer" 
     MemberDefinition="CertificateStore"/>
  4. Add Settings to the Resources

    As a general guideline, use a setting when you need to add an entity which is an attribute of another SDM object. Typically, a setting has an identity only by virtue of the object that it qualifies, so it is anonymous by itself. To make the certificate resource sample more interesting, you need to add some settings. You will add a few settings to the certificate and simply give the certificate store a name. For simplicity, all of the settings are defined as strings and only a few of them are listed here. Add the following setting declarations to the resource definitions in the SDM document. See ResourceDefinition (SystemDefinitionModel) Element which in turn is of type ResourceDefinition Complex Type for details of the structure of a resource definition. Replace the previous resource definitions with the following XML code containing resources with settings.

    [XML]

    <!--
     Resource Definitions
     -->
    <ResourceDefinition 
     Name="CertificateStore" 
     Layer="ApplicationHost" 
     Abstract="true">
            <SettingDeclaration 
             Name="Name" 
             Definition="String" />
    </ResourceDefinition>
    
    <ResourceDefinition 
     Name="X509Certificate" 
     Layer="Application" 
     Abstract="true">
            <SettingDeclaration Name="SerialNumber" Definition="String" />
            <SettingDeclaration Name="AlgorithmId" Definition="String" />
            <SettingDeclaration Name="IssuerName" Definition="String" />
            <SettingDeclaration 
             Name="EnhancedKeyUsage" 
             Definition="String" List="true" />
    </ResourceDefinition>

    Compile the .sdm document again using the same SdmC.exe command as above to ensure validity of the new XML blocks.

  5. Create Custom Type Definitions

    Instead of allowing the settings in the previous steps to be unrestricted strings, you can customize them to be restricted to certain inputs. The setting definitions allow you to define custom types that will provide validation for the settings. Here are two custom setting definitions that are provided in the certificates sample.

    • HexStringType: This is a custom type for representing a hex-encoded number. Only strings that contain numbers or letters (upper or lower case) of length greater than zero will be allowed. The <xs:pattern> enforces the regular expression that represents a hex-encoded number.
    • EnhancedKeyUsageType: This custom enumeration type specifies the values in an allowed.

    The following XML code shows the XSD definitions for these two custom types.

    [XML]

    <xs:simpleType name="HexStringType">
    <xs:annotation>
        <xs:documentation>
         Defines a type for representing a hex encoded number.
        </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
        <xs:pattern value="[0-9A-Fa-f]+" />
    </xs:restriction>
    

</xs:simpleType> <xs:simpleType name="EnhancedKeyUsageType"> <xs:annotation> <xs:documentation> Defines an enumeration for enhanced key usage. </xs:documentation> </xs:annotation> <xs:restriction base="xs:string"> <xs:enumeration value="ClientAuthentication" /> <xs:enumeration value="ServerAuthentication" /> <xs:enumeration value="EmailProtection" /> <xs:enumeration value="CodeSigning" /> <xs:enumeration value="TimeStampSigning" /> <xs:enumeration value="IPSec" /> <xs:enumeration value="Other" /> </xs:restriction> </xs:simpleType>

  1. Create a Setting Definition that contains the custom Types

    All of the simple and complex types used to define the setting definitions must be contained in the <xs:schema> element. Here is a skeleton of the setting definition that is necessary to get the document containing the setting definitions to compile. For more information, see SettingDefinitions (SystemDefinitionModel) Element.

    Adding setting definitions requires a manager. The manager is an assembly that contains the CLR types that correspond to the types used in the XSD. When SDM deals with types, the types must be translated from XML into CLR types. A command-line tool is provided to translate from the setting definitions in the schema into C# types. This tool is called the manager generator (SdmG.exe). The manager generator produces a C# source file, which must be compiled into an assembly using the C# compiler. The next step shows how to generate the C# code and compile it to create the assembly. Add the <Manager> element here to include the dll that will be generated.

    [XML]

    <!--
    

Setting Definitions --> <SettingDefinitions Manager="CertManager" ClrNamespace="Microsoft.Sdm.Samples.Certificates"> <xs:schema xmlns:xs="https://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" xmlns="https://Microsoft.Samples.Certificates" targetNamespace="https://Microsoft.Samples.Certificates"> <xs:simpleType name="HexStringType"> <xs:annotation> <xs:documentation> Defines a type for representing a hex encoded number. </xs:documentation> </xs:annotation> <xs:restriction base="xs:string"> <xs:pattern value="[0-9A-Fa-f]+" /> </xs:restriction> </xs:simpleType> <xs:simpleType name="EnhancedKeyUsageType"> <xs:annotation> <xs:documentation> Defines an enumeration for enhanced key usage. </xs:documentation> </xs:annotation> <xs:restriction base="xs:string"> <xs:enumeration value="ClientAuthentication" /> <xs:enumeration value="ServerAuthentication" /> <xs:enumeration value="EmailProtection" /> <xs:enumeration value="CodeSigning" /> <xs:enumeration value="TimeStampSigning" /> <xs:enumeration value="IPSec" /> <xs:enumeration value="Other" /> </xs:restriction> </xs:simpleType> </xs:schema> </SettingDefinitions>

<!-- Manager --> <Manager Name="CertManager" AssemblyName="Microsoft.Sdm.Samples.Certs" SourcePath="Microsoft.Sdm.Samples.Certs.dll" />

  1. Generate the C# code using SdmG.exe.

    Use the following command to generate the C# code for the custom types:

    SdmG.exe Microsoft.Samples.Certificates.sdm /R Microsoft.Configuration.sdmdocument /R Microsoft.Data.sdmdocument /R Microsoft.DistributedApplication.sdmdocument /R Microsoft.FileSystem.sdmdocument /R Microsoft.InternetInformationServices.sdmdocument /R Microsoft.OperatingSystem.sdmdocument /R Microsoft.WindowsApplication.sdmdocument /R Microsoft.WindowsHost.sdmdocument /R Microsoft.Web.sdmdocument /R Microsoft.WebHost.sdmdocument /R Microsoft.WebApplication.sdmdocument /R System.Constraints.sdmdocument /R System.Flow.sdmdocument /SearchPath "%SdmModelsDir%\" /Classes Microsoft.Samples.Certs.cs /Settings+ /Resources Microsoft.Sdm.Samples.Certs.resources

    SdmG.exe will generate the following C# code and put it in Microsoft.Samples.Certs.cs. For more information, see SDM Manager Generator (SdmG.exe). The resource descriptions create a file called Microsoft.Sdm.Samples.Certs.resources. Note that the name of the .cs file and the name of the .resources file must be the same except for the extensions.

    [C#]

[System.Xml.Serialization.XmlTypeAttribute(Namespace="https://Microsoft.Samples.Certificates")] public enum EnhancedKeyUsageType {

    ClientAuthentication,
    
    ServerAuthentication,
    
    EmailProtection,
    
    CodeSigning,
    
    TimeStampSigning,
    
    IPSec,
    
    Other,

}

[System.Xml.Serialization.XmlTypeAttribute(Namespace = "https://Microsoft.Samples.Certificates")] public partial class HexStringType {

[System.Xml.Serialization.XmlTextAttribute(Type = typeof(string))]
public string Value;

public override bool Equals(object obj)
{
    if ((obj == null))
    {
        return false;
    }
    if ((this.GetType() != obj.GetType()))
    {
        return false;
    }
    HexStringType other = ((HexStringType)(obj));
    if ((object.Equals(this.Value, other.Value) == false))
    {
        return false;
    }
    return true;
}

public override int GetHashCode()
{
    int hashCode = 0;
    if ((this.Value != null))
    {
        hashCode = hashCode ^ this.Value.GetHashCode();
    }
    return hashCode;
}

public virtual HexStringType Copy()
{
    HexStringType copy = new HexStringType();
    copy.Value = this.Value;
    return copy;
}

public override string ToString()
{
    return string.Format(System.Globalization.CultureInfo.CurrentUICulture, 
                         "{0}", 
                         this.Value);
}

}

  1. Run the C# compiler to generate Microsoft.Samples.Certs.dll from the above .cs file:

    CsC.exe /noconfig /reference:%V2ClrInstallDir%\System.xml.dll **/out:**Microsoft.Sdm.Samples.Certs.dll **/resource:**Microsoft.Sdm.Samples.Certs.resources **/target:**library Microsoft.Sdm.Samples.Certs.cs

    This is the DLL that was mentioned in the Manager element in the previous step.

    [XML]

<!-- Manager --> <Manager Name="CertManager" AssemblyName="Microsoft.Sdm.Samples.Certs" SourcePath="Microsoft.Sdm.Samples.Certs.dll" />

  1. Update the setting declarations to use new setting definitions.

    Change the setting declarations on the certificate resource to use the new setting definitions.

    • SerialNumber should be a hexadecimal number, so use the HexStringType setting definition.
    • EnhancedKeyUsage should only allow values from an enumeration, so use the new EnhancedKeyUsage setting definition.

    [XML]

    <ResourceDefinition Name="X509Certificate" Layer="Application" Abstract="true">
        <SettingDeclaration Name="SerialNumber" Definition="HexStringType" />
        <SettingDeclaration Name="AlgorithmId" Definition="String" />
        <SettingDeclaration Name="IssuerName" Definition="String" />
        <SettingDeclaration Name="EnhancedKeyUsage" Definition="EnhancedKeyUsageType" 
                            List="true" />
    
    </ResourceDefinition>
  2. Localize the document (optional).

    If you need to localize the descriptions in a .sdm file:

    1. Add the Manager and ResourceId attributes to each <Description> and <Entry> element.
    2. Run the manager generator to extract the descriptions from the SDM document and produce a .resources file that contains all the localizable strings.
    3. Compile the manager assembly to include the .resources along with other code in the manager.
    4. Set the DocumentLanguage attribute on the root <SystemDefinitionModel> element to the default language, which is the language in which the descriptions are written in the SDM document.
    5. Finally, localize the manager assembly as you would localize any other CLR assembly. The following XML shows an example of a description that will need to be localized.

    [XML]

    <Description 
    

Manager="CertManager" ResourceId="DocumentDescription"> SDM model for certificate resources </Description>

  1. Add constraints to settings (optional).

    At this point, it is possible to add constraints to the above defined relationships. For more information, see the topic How to: Create a Constraint on a Relationship. The next step shows the SDM document created thus far. The SDM document with the addition of a constraint is described in How to: Create a Constraint on a Relationship.

  2. Completed Certificates Sample .sdm File.

    Here is the complete Microsoft.Samples.Certificates.sdm file for the certificates example that includes all the XML mentioned in the above steps.

    [XML]

    <?xml version="1.0" encoding="UTF-8"?>
    

<SystemDefinitionModel Name="Microsoft.Samples.Certificates" Version="1.0.0.0" DocumentLanguage="en" xmlns="https://schemas.microsoft.com/SystemDefinitionModel/2005/1"> <Information> <FriendlyName>Sample certificate model</FriendlyName> <CompanyName>Microsoft Corporation</CompanyName> <Copyright> Copyright (c) Microsoft Corporation.
All rights reserved.
This is provided AS IS with no warranties, and confers no rights. </Copyright> <Description Manager="CertManager" ResourceId="DocumentDescription"> SDM model for certificate resources </Description> </Information> <!-- Imports --> <Import Alias="WindowsHost" Name="Microsoft.WindowsHost" /> <Import Alias="WindowsApp" Name="Microsoft.WindowsApplication" /> <Import Alias="IIS" Name="Microsoft.InternetInformationServices" /> <Import Alias="WebHost" Name="Microsoft.WebHost" /> <Import Alias="WebApp" Name="Microsoft.WebApplication" /> <Import Alias="FileSystem" Name="Microsoft.FileSystem" /> <Import Alias="Constraints" Name="System.Constraints" /> <Import Alias="Flow" Name="System.Flow"/> <!-- Setting definitions --> <SettingDefinitions Manager="CertManager" ClrNamespace="Microsoft.Sdm.Samples.Certificates"> <xs:schema xmlns:xs="https://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" xmlns="https://Microsoft.Samples.Certificates" targetNamespace="https://Microsoft.Samples.Certificates"> <xs:simpleType name="HexStringType"> <xs:annotation> <xs:documentation> Defines a type for representing a hex encoded number. </xs:documentation> </xs:annotation> <xs:restriction base="xs:string"> <xs:pattern value="[0-9A-Fa-f]+" /> </xs:restriction> </xs:simpleType> <xs:simpleType name="KeyUsageType"> <xs:annotation> <xs:documentation> Defines an enumeration for key usage. </xs:documentation> </xs:annotation> <xs:restriction base="xs:string"> <xs:enumeration value="DigitalSignature" /> <xs:enumeration value="NonRepudiation" /> <xs:enumeration value="KeyEncryption" /> <xs:enumeration value="DataEncryption" /> <xs:enumeration value="KeyAgreement" /> <xs:enumeration value="CertificateValidation" /> <xs:enumeration value="CRLValidation" /> </xs:restriction> </xs:simpleType> <xs:simpleType name="EnhancedKeyUsageType"> <xs:annotation> <xs:documentation> Defines an enumeration for enhanced key usage. </xs:documentation> </xs:annotation> <xs:restriction base="xs:string"> <xs:enumeration value="ClientAuthentication" /> <xs:enumeration value="ServerAuthentication" /> <xs:enumeration value="EmailProtection" /> <xs:enumeration value="CodeSigning" /> <xs:enumeration value="TimeStampSigning" /> <xs:enumeration value="IPSec" /> <xs:enumeration value="Other" /> </xs:restriction> </xs:simpleType> <xs:complexType name="PropertyValuePairType"> <xs:sequence> <xs:element name="Property" type="xs:string" /> <xs:element name="Value" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:schema> </SettingDefinitions> <!-- Resource Definitions --> <ResourceDefinition Name="CertificateStore" Layer="ApplicationHost" Abstract="true"> <SettingDeclaration Name="Name" Definition="String" /> </ResourceDefinition> <ResourceDefinition Name="X509Certificate" Layer="Application" Abstract="true"> <!-- X509 V3 settings --> <SettingDeclaration Name="Version" Definition="String" /> <SettingDeclaration Name="SerialNumber" Definition="HexStringType" /> <SettingDeclaration Name="AlgorithmId" Definition="String" /> <SettingDeclaration Name="AlgorithmParameters" Definition="String" List="true" /> <SettingDeclaration Name="IssuerName" Definition="String" /> <SettingDeclaration Name="ValidFrom" Definition="DateTime" /> <SettingDeclaration Name="ValidTo" Definition="DateTime" /> <SettingDeclaration Name="SubjectName" Definition="String" /> <SettingDeclaration Name="PublicKey" Definition="HexStringType" /> <SettingDeclaration Name="PublicKeyAlgorithm" Definition="String" /> <SettingDeclaration Name="PublicKeyParameters" Definition="String" List="true" /> <SettingDeclaration Name="Signature" Definition="String" /> <SettingDeclaration Name="IssuerId" Definition="String" /> <SettingDeclaration Name="SubjectId" Definition="HexStringType" /> <SettingDeclaration Name="Extensions" Definition="PropertyValuePairType" List="true" /> <!-- Key and Policy extensions --> <SettingDeclaration Name="AuthorityKeyId" Definition="HexStringType" /> <SettingDeclaration Name="SubjectKeyId" Definition="HexStringType" /> <SettingDeclaration Name="KeyUsage" Definition="KeyUsageType" List="true" /> <SettingDeclaration Name="PrivateKeyUsagePeriod" Definition="String" /> <SettingDeclaration Name="CertificatePolicies" Definition="String" List="true" /> <SettingDeclaration Name="PolicyMappings" Definition="String" List="true" /> <!-- Certificate Subject and Issuer Extensions --> <SettingDeclaration Name="SubjectAlternativeName" Definition="String" List="true" /> <SettingDeclaration Name="IssuerAlternativeName" Definition="String" List="true" /> <SettingDeclaration Name="SubjectDirectoryAttributes" Definition="String" List="true" /> <!-- Certification Path Constraints --> <SettingDeclaration Name="BasicConstraints" Definition="String" List="true" /> <SettingDeclaration Name="NameConstraints" Definition="String" List="true" /> <SettingDeclaration Name="PolicyConstraints" Definition="String" List="true" /> <!-- Other extensions --> <SettingDeclaration Name="EnhancedKeyUsage" Definition="EnhancedKeyUsageType" List="true" /> <SettingDeclaration Name="Thumbprint" Definition="HexStringType" /> <SettingDeclaration Name="ThumbprintAlgorithm" Definition="String" /> </ResourceDefinition>

&lt;!--
Relationship Definitions
--&gt;
&lt;!--
Certificate containment relationships
--&gt;
&lt;ContainmentDefinition 
 Name="WindowsApplicationContainsCertificate" 
 ParentDefinition="WindowsApp:WindowsApplication" 
 MemberDefinition="X509Certificate"&gt;
    &lt;Description 
     Manager="CertManager" 
     ResourceId="WindowsApplicationContainsCertificate"&gt;
     A WindowsApplication system can contain certificate resources.
    &lt;/Description&gt;
&lt;/ContainmentDefinition&gt;
&lt;ContainmentDefinition 
 Name="WebApplicationContainsCertificate" 
 ParentDefinition="WebApp:WebApplication" 
 MemberDefinition="X509Certificate"&gt;
    &lt;Description 
     Manager="CertManager" 
     ResourceId="WebApplicationContainsCertificate"&gt;
     A WebApplication system can contain certificate resources.&lt;/Description&gt;
&lt;/ContainmentDefinition&gt;
&lt;!--
Certificate store containment relationships
--&gt;
&lt;ContainmentDefinition 
 Name="WindowsHostContainsCertificateStore" 
 ParentDefinition="WindowsHost:WindowsHost" 
 MemberDefinition="CertificateStore"&gt;
    &lt;Description 
     Manager="CertManager" 
     ResourceId="WindowsHostContainsCertificateStore"&gt;
     A WindowsHost system can contain certificate store resources.
    &lt;/Description&gt;
&lt;/ContainmentDefinition&gt;    
&lt;ContainmentDefinition 
 Name="WebServerContainsCertificateStore" 
 ParentDefinition="WebHost:WebServer" 
 MemberDefinition="CertificateStore"&gt;
    &lt;Description 
     Manager="CertManager" 
     ResourceId="WebServerContainsCertificateStore"&gt;
     A WebServer can contain a certificate store.
    &lt;/Description&gt;
&lt;/ContainmentDefinition&gt;    


&lt;!--
CertificateStore hosts a Certificate, 
although this isn't used by the design surface.
--&gt;
&lt;!--
Hosting Definitions
--&gt;
&lt;HostingDefinition 
 Name="CertificateStoreHostsCertificate" 
 HostDefinition="CertificateStore" 
 GuestDefinition="X509Certificate"&gt;
    &lt;Description 
     Manager="CertManager" 
     ResourceId="CertificateStoreHostsCertificate"&gt;
     A certificate store can host certificates.
    &lt;/Description&gt;
&lt;/HostingDefinition&gt;

&lt;!--
Manager 
--&gt;
&lt;Manager 
 Name="CertManager" 
 AssemblyName="Microsoft.Sdm.Samples.Certs" 
 SourcePath="Microsoft.Sdm.Samples.Certs.dll" /&gt;

</SystemDefinitionModel>

  1. Compile this SDM document once again using the command line below to make sure it validates.

    This will create a Microsoft.Samples.Certificates.sdmdocument file which can then be loaded in the setup step below.

    SdmC.exe Microsoft.Samples.Certificates.sdm /Output Microsoft.Samples.Certificates.sdmdocument /Reference Microsoft.Configuration.sdmdocument /r Microsoft.Data.sdmdocument /r Microsoft.DistributedApplication.sdmdocument /r Microsoft.FileSystem.sdmdocument /r Microsoft.InternetInformationServices.sdmdocument /r Microsoft.OperatingSystem.sdmdocument /r Microsoft.WindowsApplication.sdmdocument /r Microsoft.WindowsHost.sdmdocument /r Microsoft.Web.sdmdocument /r Microsoft.WebHost.sdmdocument /r Microsoft.WebApplication.sdmdocument /r System.Constraints.sdmdocument /r System.Flow.sdmdocument /SearchPath "%SdmModelsDir%\"

  2. Setup

    After an SDK user has created a validated (compiled) .sdmdocument file (and corresponding prototypes and bitmaps where applicable), it needs to be installed so that it it is visible on the design surface to be picked up and worked on. Visual Studio loads a number of models (compiled .sdmdocument files) when a distributed system application is opened or created. To instruct Visual Studio to load your model during startup, you need to add the full path to your model in a registry key. In Visual Studio 2005, the registry key is:

    HKLM\Software\Microsoft\VisualStudio\
         8.0\EnterpriseTools\Sdm\InitializationFiles

    In Visual Studio Team System 2008 Architecture Edition, the registry key is:

    HKLM\Software\Microsoft\VisualStudio\
         9.0\EnterpriseTools\Sdm\InitializationFiles

    There is one entry per model that needs to be loaded during startup. Consider the following when adding a value to this key for your model.

    • Add one value for each model you are installing.
    • The name of the value is typically the name of the file without the .sdmdocument extension. The data value is the full path to your model. If C:\SdmSamples were the name of the directory in which you are creating the samples, then an example of an entry for this certificates model would be: Microsoft.Samples.Certificates = C:\SdmSamples\Microsoft.Samples.Certificates.sdmdocument.
    • The name of the registry value determines the order in which the models are loaded.The models get loaded alphabetically from the registry key according to the name. For your model to be loaded correctly, all models imported by your model must be loaded before your model. To guarantee loading in the correct order, the recommendation is: add a numerical prefix to the name of your file while creating the registry value. The prefix must be greater than the numbers of the models that your model imports. If your model does not import any documents, you should still use a number for consistency.

    This step loads the document. The resources are ready to be used by an SDM system in the designer. You can add/modify/remove a resource using the Settings and Constraints Editor in the designer. An example of an SDM system that uses these resources is described in How to: Create an SDM system.

See Also

How to: Create an SDM Document
How to: Create a Setting Constraint
ResourceDefinition (SystemDefinitionModel) Element
SettingDefinitions (SystemDefinitionModel) Element

Send comments about this topic to Microsoft

Build date: 10/2/2007