March 2005 - Posts - Greg Collins
in

InfoPath Dev

This Blog

Syndication

Greg Collins

March 2005 - Posts

  • Visual Studio Debugging: "Unable to Attach to Application" Error

    If you have installed an application that uses .NET Framework 2.0, you might suddenly find that you can no longer debug your managed code InfoPath forms. This can be very frustrating, but is easily fixed with the following steps:

    1. Shut down Visual Studio.
    2. Open Notepad and copy the following XML into it:

    <configuration>
        <startup>
            <requiredRuntime imageVersion="v1.1.4322" version="v1.1.4322" />
            <supportedRuntime version="v1.1.4322" />
        </startup>
    </configuration>

    1. Save the file to the same folder as the InfoPath application as InfoPath.exe.config.

    The default folder is C:\Program Files\Microsoft Office\OFFICE11.

    1. Launch Visual Studio, open an InfoPath project, and run the debugger.

    The file you just created directs InfoPath to run in the context of .NET Framework 1.1 instead of 2.0.

    ©2005 Greg Collins. All rights reserved. Licensed to Autonomy Systems, LLC for display on InfoPathDev.com.

  • Preserve Code Blocks (xd:preserve) and Input Tags

    InfoPath allows you, the template developer, to manually modify templates to include XSL features that are not directly supported from within the InfoPath designer. These are called Preserve Code Blocks.

    To create a Preserve Code Block, simply change the mode attribute for both the xsl:template and the xsl:apply-templates to have a value of xd:preserve.

    One known issue is that on roundtripping your template in the designer, InfoPath will move the closing input tag to immediately after the opening tag.

    For example:

    <input class="xdBehavior_Boolean" title="" type="radio" name="{generate-id(my:field1)}" xd:binding="my:field1" xd:boundProp="xd:value" xd:onValue="1" tabIndex="0" xd:xctname="OptionButton" xd:CtrlId="CTRL1">
        <xsl:attribute name="xd:value">
            <xsl:value-of select="my:field1"/>
        </xsl:attribute>
        <xsl:if test="my:field1=&quot;1&quot;">
            <xsl:attribute name="CHECKED">CHECKED</xsl:attribute>
        </xsl:if>
    </input> Radio Button 1

    Will be changed to:

    <input class="xdBehavior_Boolean" title="" type="radio" name="{generate-id(my:field1)}" xd:binding="my:field1" xd:boundProp="xd:value" xd:onValue="1" tabIndex="0" xd:xctname="OptionButton" xd:CtrlId="CTRL1"></input>
        <xsl:attribute name="xd:value">
            <xsl:value-of select="my:field1"/>
        </xsl:attribute>
        <xsl:if test="my:field1=&quot;1&quot;">
            <xsl:attribute name="CHECKED">CHECKED</xsl:attribute>
        </xsl:if>
    Radio Button 1

    Because of this change, the xsl:attributes will no longer be applied, as they should, to the opening tag. This effectively disables the radio buttons.

    To resolve this issue, you must convert your input tag to an xsl:element, as shown here:

    <xsl:element name="input">
        <xsl:attribute name="class">
            <xsl:value-of select="xdBehavior_Boolean"/>
        </xsl:attribute>
        <xsl:attribute name="type">
            <xsl:value-of select="radio" />
        </xsl:attribute>
        <xsl:attribute name="name">
            <xsl:value-of select="{generate-id(my:field1)}"/>
        </xsl:attribute>
        <xsl:attribute name="xd:binding">
            <xsl:value-of select="my:field1"/>
        </xsl:attribute>
        <xsl:attribute name="xd:boundProp".
            <xsl:value-of select="xd:value"/>
        </xsl:attribute>
        <xsl:attribute name="xd:onValue">
            <xsl:value-of select="1"/>
        </xsl:attribute>
        <xsl:attribute name="tabIndex">
            <xsl:value-of select="0"/>
        </xsl:attribute>
        <xsl:attribute name="xd:xctname">
            <xsl:value-of select="OptionButton"/>
        </xsl:attribute>
        <xsl:attribute name="xd:CtrlId">
            <xsl:value-of select="CTRL1"/>
        </xsl:attribute>
        <xsl:attribute name="xd:value">
            <xsl:value-of select="my:field1"/>
        </xsl:attribute>
        <xsl:if test="my:field1=&quot;1&quot;">
            <xsl:attribute name="CHECKED">CHECKED</xsl:attribute>
        </xsl:if>
    </xsl:element> Radio Button 1

    ©2005 Greg Collins. All rights reserved. Licensed to Autonomy Systems, LLC for display on InfoPathDev.com.

Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.