MRefBuilder invalid character

Apr 6, 2010 at 9:38 PM

I'm trying to run the mrefbuilder but it keeps throwing the following exception:

 

 MrefBuilder (v2.4.10520.1)
  Copyright c Microsoft 2006
  Info: Loaded 1 assemblies for reflection and 15 dependency assemblies.
  
  Unhandled Exception: System.ArgumentException: '', hexadecimal value 0x02, is an invalid character.
     at System.Xml.XmlEncodedRawTextWriter.InvalidXmlChar(Int32 ch, Char* pDst, Boolean entitize)
     at System.Xml.XmlEncodedRawTextWriter.WriteAttributeTextBlock(Char* pSrc, Char* pSrcEnd)
     at System.Xml.XmlEncodedRawTextWriter.WriteString(String text)
     at System.Xml.XmlEncodedRawTextWriterIndent.WriteString(String text)
     at System.Xml.XmlWellFormedWriter.WriteString(String text)
     at System.Xml.XmlWriter.WriteAttributeString(String localName, String value)
     at Microsoft.Ddue.Tools.ManagedReflectionWriter.WriteTypeElements(TypeNode type)
     at Microsoft.Ddue.Tools.ManagedReflectionWriter.WriteType(TypeNode type)
     at Microsoft.Ddue.Tools.ManagedReflectionWriter.VisitType(TypeNode type)
     at Microsoft.Ddue.Tools.Reflection.ApiVisitor.VisitTypes(TypeNodeList types)
     at Microsoft.Ddue.Tools.Reflection.ApiVisitor.VisitNamespace(Namespace space)
     at Microsoft.Ddue.Tools.ManagedReflectionWriter.VisitNamespace(Namespace space)
     at Microsoft.Ddue.Tools.Reflection.ApiVisitor.VisitNamespaces(NamespaceList spaces)
     at Microsoft.Ddue.Tools.ManagedReflectionWriter.VisitNamespaces(NamespaceList spaces)
     at Microsoft.Ddue.Tools.Reflection.ApiVisitor.VisitApis()
     at Microsoft.Ddue.Tools.MRefBuilder.Main(String[] args)

 MrefBuilder (v2.4.10520.1)

  Copyright c Microsoft 2006

  Info: Loaded 1 assemblies for reflection and 15 dependency assemblies.

 

  Unhandled Exception: System.ArgumentException: '', hexadecimal value 0x02, is an invalid character.

     at System.Xml.XmlEncodedRawTextWriter.InvalidXmlChar(Int32 ch, Char* pDst, Boolean entitize)

     at System.Xml.XmlEncodedRawTextWriter.WriteAttributeTextBlock(Char* pSrc, Char* pSrcEnd)

     at System.Xml.XmlEncodedRawTextWriter.WriteString(String text)

     at System.Xml.XmlEncodedRawTextWriterIndent.WriteString(String text)

     at System.Xml.XmlWellFormedWriter.WriteString(String text)

     at System.Xml.XmlWriter.WriteAttributeString(String localName, String value)

     at Microsoft.Ddue.Tools.ManagedReflectionWriter.WriteTypeElements(TypeNode type)

     at Microsoft.Ddue.Tools.ManagedReflectionWriter.WriteType(TypeNode type)

     at Microsoft.Ddue.Tools.ManagedReflectionWriter.VisitType(TypeNode type)

     at Microsoft.Ddue.Tools.Reflection.ApiVisitor.VisitTypes(TypeNodeList types)

     at Microsoft.Ddue.Tools.Reflection.ApiVisitor.VisitNamespace(Namespace space)

     at Microsoft.Ddue.Tools.ManagedReflectionWriter.VisitNamespace(Namespace space)

     at Microsoft.Ddue.Tools.Reflection.ApiVisitor.VisitNamespaces(NamespaceList spaces)

     at Microsoft.Ddue.Tools.ManagedReflectionWriter.VisitNamespaces(NamespaceList spaces)

     at Microsoft.Ddue.Tools.Reflection.ApiVisitor.VisitApis()

     at Microsoft.Ddue.Tools.MRefBuilder.Main(String[] args)

The problem is, I don't have any clue where that character might be used at.  I ran my xml file through the W3C validator and it came up clean.
Anyone have any ideas?

 

Editor
Apr 7, 2010 at 3:15 AM

It's parsing the assembly, not the XML comments file.  Is the assembly obfuscated?  If so, MRefBuilder doesn't handle them very well especially if you are documenting the internal and private members.  Using an unobfuscated version of the assembly would work around the problem if that's the case.  Another possibility is that you've got a constant that contains that value either literally or in hex form (see this thread:  http://social.msdn.microsoft.com/Forums/en-US/devdocs/thread/8a7e006e-12dc-4456-b656-7903ce120dc5).

Eric

 

Apr 7, 2010 at 7:43 PM
Edited Apr 7, 2010 at 8:11 PM

It is not an obfuscated assembly.  

Does signing have any impact?  Because this assembly is signed.

I went through all my constants and didn't find any assigned a value of 2.  Based on your referenced thread, I changed all of my consts to static readonly's just so they don't cause problems later on.

However, I did find 2 or 3 enums that have a value of 2.  Two of them were enums set up to access advapi32.dll, which I do a [DllImport()] on.  I've tried with the assignment = 2 and without it, but it still is causing the same error.

 

Edit:

I started testing it out manually with the MRefBuilder command line.  I went brute force and excluded ALL of my namespaces.  Then I added 1 at a time until I found the culprit.  

How do I edit the config file used by the Help File Builder?  It doesn't appear to be picking up the changes to the config file for MRefBuilder

Editor
Apr 7, 2010 at 8:31 PM
Edited Apr 7, 2010 at 8:31 PM

Signing won't affect the assembly.  If you're just trying to exclude a namespace, type, or member via the API filter, use the project's APIFilter property.  If you're modifying something else in the config file, the template used by SHFB is in the .\Templates folder in the main SHFB installation folder.

Eric

 

Apr 7, 2010 at 8:32 PM

I ended up using the <exclude> tags, because the API Filter always errored out while trying to load.   Perhaps because of the same MRef error, not sure.  But as I type I see it's generating a HTML Help file, so I think I'm just about there.

 

Thanks for you help.

 

 

Editor
Apr 8, 2010 at 3:25 AM

I forgot that the API filter designer uses a partial build so that would fail for the same reason.  Just in case anyone else runs into this, can you give an example of the members that were causing the problem?  Opening a work item may not hurt either since it does appear to be bug in MRefBuilder.

Eric

 

Apr 8, 2010 at 1:52 PM

It appears to be the namespace that uses a DLL from http://www.theobald-software.com/en/products/erpconnect.htm

This allows our software to connect directly to SAP.  They provided a Linq-to-SAP type interface, and from all appearances that is what caused it.

Apr 8, 2010 at 2:56 PM

Hi,

Then it's quite possible that a constant defined in their library is being inlined in yours.  Take a look with Reflector to see.

- Dave