Showing posts with label XML. Show all posts
Showing posts with label XML. Show all posts

Wednesday, July 1, 2015

WPF Error: System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.

image

This was coming after successful compile but while executing the application.. However, after searching, from one post on StackOverFlow I got know that one of the image in my Resource is not in proper uri. That’s what I corrected and it started working fine.

Initially it was:

<Border.Background>             
      <ImageBrush ImageSource="Resources/BG-horizontal.png" />
</Border.Background>



And when changed to following, it started working fine: See highlighted change.

<Border.Background>             
      <ImageBrush ImageSource="../Resources/BG-horizontal.png" />
</Border.Background>
 

Thursday, September 18, 2014

Displaying <![CDATA[]]> literally in XML while escaping end token.

While adding XML Code Snippets for WIX (Windows Installer XML), I had to write XML containing <![CDATA[Installed OR NETFRAMEWORK40FULL]]>.
Problem arises, where Visual Studio Code Snippets uses <![CDATA[your snippet code here]]> to store the code and it can’t have another <![CDATA[]]> inside it. So it was not accepting this:
<Code Language="xml">
<![CDATA[
<PropertyRef Id="$NETFRAMEWORK40FULL$"/>
  <Condition Message="This application requires Microsoft .NET Framework 4.0 Runtime in order to run. Please install the .NET Framework and then run this installer again." >
        <![CDATA[Installed OR $NETFRAMEWORK40FULL$]]>
</Condition>
]]>
</Code>

That is, the inner <![CDATA[Installed OR $NETFRAMEWORK40FULL$]]> became a bottleneck. So making story short, after Googling, I found very good discussion on this discussion on Stack Overflow Thread and then I was able to build proper XML by escaping ]]>. Here is my solved snippet code:
    <Code Language="xml">    
      <![CDATA[<PropertyRef Id="$NETFRAMEWORK40FULL$"/>
      <Condition Message="This application requires Microsoft .NET Framework 4.0 Runtime in order to run. Please install the .NET Framework and then run this installer again." >
          <![CDATA[Installed OR $NETFRAMEWORK40FULL$]]]]><![CDATA[>
       </Condition>]]>      
    </Code>

See the breaking code into chunks and put in multiple uses of <![CDATA[]]>… Do read Escaping CDATA end token for more info.