Summary: Tips/Techniques/Etcetera for working with the Visio 2003 Drawing Control


Blogs on Visio


Mai-lan's "Blogging on Visio" -- http://blogs.msdn.com/mailant/


IVEventList.AddAdvise and the ComVisible Attribute


If you're using the AddAdvise method on an EventList, the class that you pass to AddAdvise (the event sink) must NOT be in a scope that has ComVisible(false) set.

If it is in a scope that has ComVisible(false), the call to AddAdvise will throw an exception with the helpful message "An exception occurred."


Using XmlSerializer To Write an Instance into SolutionXML


You can use XmlSerializer to store instance data into the SolutionXML cell of a document. However, you cannot immediately use the string written to a StringWriter. You first need to strip off the first line of the string:

		 <?xml version="1.0" encoding="utf-16"?>
	

Otherwise, the call to set_SolutionXML() will fail with the exception "Invalid Parameter." I've used the following code to strip off this header:

		 [XmlSerializer] writer = new [XmlSerializer(] m_MemberItems.GetType(), [VisioUtilities.NamespaceAttributePrefix] + [VisioUtilities.NamespacePrefix] );
	

		 [StringWriter] stringWriter = new [StringWriter();]
		 writer.Serialize( stringWriter, m_MemberItems );
	

		 string xmlString = [stringWriter.ToString();]
		 int [iEndPos] = [xmlString.IndexOf(] "?>" );
	

		 xmlString = xmlString.Substring( [iEndPos] + 2 );
	
Microsoft Communities