We have a VSTO add-in written in VB.Net 3.5 and running in MS Word 2010. In this VSTO add-in we set a number of SharePoint (2010) Meta Properties that are returned from the documents ContentTypeProperties collection.
Sometimes (quite regularly, but not all the time) when we set the Value property of a MetaData item that is of type msoMetaPropertyTypeLookup it causes Word to crash. Obviously there is a try catch around the setting of the Value, but no exception is caught by it - Word just dies. Details about the Word error is below, but I suspect it will not be much use to anyone. For fields that are of type text, there is no issue in setting their values.
It would be very much appreciative if someone was able to point us in the right direction to always be able to set the Value of a lookup metadata property in a way that doesn't kill word!
Also we have one MetaData property that is also a lookup type, but just accessing any of it's properties (such as value, name, type) causes the following exception "Element not found. (Exception from HRESULT: 0x80070490)"
The only property that seems to not cause this exception is the Id property. The only difference I can see is that the name of the field has a forward slash in it ("/"). Is the "/" invalid in a field name?
The Default DIP can set all values without issues. It is just when we try and do it in code that we run into issues.
Problem signature:
Problem Event Name: APPCRASH
Application Name: WINWORD.EXE
Application Version: 14.0.5123.5000
Application Timestamp: 4c646b38
Fault Module Name: StackHash_6608
Fault Module Version: 6.1.7600.16695
Fault Module Timestamp: 4cc7ab44
Exception Code: c0000374
Exception Offset: 000c35e3
OS Version: 6.1.7600.2.0.0.256.48
Locale ID: 5129
Additional Information 1: 6608
Additional Information 2: 66081020834161d0adf96c6191f1a84c
Additional Information 3: fdd5
Additional Information 4: fdd5bad4f069a755d9154e340782caad
I had the same issue and I found in the ContentTypeProperties's Schema Xml that the internal names for the fields had a 0 at the end, like CustomSiteColumnName0
however the name of the field did not. It was because of the content type had a custom parent content type that also had some site columns, but those columns had the internal names fine in the SchemaXml.
So after removing the columns from the parent content type, fortunately I did not use them at all, everything just started to work properly in a new document based on the custom content type.
I tried the same in VBA and encountered the same error just enumerating the Properties from a sharepoint hosted document.
Sub GetDocProps()
Dim i As Long
Dim prop As Office.MetaProperty
Dim props As Office.MetaProperties
Set props = ActiveDocument.ContentTypeProperties
i = 1
For Each prop In props
' Debug.Print i & ". Type: " & prop.Type & " ID: " & prop.ID & " Name: " & prop.Name & " Value: " & prop.Value
Debug.Print i & "." & " ID: " & prop.ID & " Name: " & prop.Name
i = i + 1
Next prop
End Sub
It crashed on the 9th property carrying a ID Intern_x002f_extern and having a column name "Internal ot External Created" Also there exist a column having a name "Afzender/Geadresseerde"
This was a Site collection which was constructed by some external consultants.
So I think those consultants did not follow the rules by using illegal characters (i.e. /
) in column name.
Breaking these rules gives all kinds of nasty side effects.
So beware of using bad column names and non-alphanumeric names in sharepoint. You'll end up shooting yourself in your foot.
regards
Marcel
User contributions licensed under CC BY-SA 3.0