我正在尝试将我的sharepoint项目分解为几个较小的项目。 我可以轻松移动不同项目中的实用程序文件。 但是当我移动自定义字段时遇到了问题。
如果我将自定义字段从ProjectA移动到ProjectB并将ProjectA设置为引用ProjectB的DLL,则构建和部署工作正常。但是,当程序从SPListItem引用自定义字段时,它将抛出System.ArgumentOutOfRangeException。
e.g。
SPListItem item = splist.GetItemById(id);<br>
CustomFieldValue custom = item["Custom"] // Error occurs here
另外,如果我调用AddFieldAsXml来定义上面的自定义字段,我会得到同样的错误。
谁能帮我解决这个问题? 提前谢谢你......AddFieldAsXml中出现错误的详细信息(引用时发生相同的错误)
Length cannot be less than zero.
Parameter name: length
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length]
System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy) +7494967
System.String.Substring(Int32 startIndex, Int32 length) +11
Microsoft.SharePoint.Publishing.PublishingHttpModule.CreateSPField(String fieldTypeName, SPFieldCollection collection, String fieldName) +80
Microsoft.SharePoint.SPFieldCollection.CreateSPField(Int32 index) +2746
Microsoft.SharePoint.SPFieldCollection.EnsureSPField(Int32 index) +89
Microsoft.SharePoint.SPFieldCollection.get_Item(Int32 iIndex) +113
Microsoft.SharePoint.SPFieldCollection.GetFieldByInternalName(String strName, Boolean bThrowException) +180
Microsoft.SharePoint.SPFieldCollection.GetFieldByInternalName(String strName) +38
Microsoft.SharePoint.SPFieldCollection.AddFieldAsXmlInternal(String schemaXml, Boolean addToDefaultView, SPAddFieldOptions op) +905
Microsoft.SharePoint.SPFieldCollection.AddFieldAsXml(String schemaXml, Boolean addToDefaultView, SPAddFieldOptions op) +45
如果string.substring(int startIndex,int length)的长度值为负,则显示此错误... 但我不知道为什么我会收到这个错误。
答案 0 :(得分:1)
我解决了这个问题...... 我没有复制fldtypes_xxxx.xml信息。 所以当代码尝试从xml中读取一些信息时,会抛出异常......