将一个SharePoint项目分解成块的问题

问题描述:

我试图将我的SharePoint项目分解为几个较小的项目。 我可以轻松地在不同的项目中移动实用程序文件。 但是当我移动自定义字段时遇到问题。将一个SharePoint项目分解成块的问题

如果我将自定义字段从ProjectA移动到ProjectB,并将ProjectA设置为引用ProjectB的DLL,则构建和部署工作正常。但是,当程序从SPListItem引用自定义字段时,它会抛出System.ArgumentOutOfRangeException。

例如

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长度)的长度值是减... 但我不知道为什么我得到这个错误。

我解决了这个问题... 我没有复制fldtypes_xxxx.xml信息。 所以当代码尝试从xml读取一些信息时,抛出异常...