将一个 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 length) 的长度值是负值,则会显示此错误... 但我不知道为什么会出现这个错误。
I'm trying to break my sharepoint project into a few smaller projects.
I could easily move utility files in different project.
However i encountered a problem when i moved custom-fields.
If i move custom-field from ProjectA to ProjectB and set ProjectA to reference ProjectB's DLL, building and deploying work fine. However, when program reference custom-field from SPListItem, it will throw System.ArgumentOutOfRangeException.
e.g.
SPListItem item = splist.GetItemById(id);<br>
CustomFieldValue custom = item["Custom"] // Error occurs here
Also, if i call AddFieldAsXml to define above custom-field, i get same error.
can anyone help me solve this problem?
thank you in advance...
Detail of Error occured in AddFieldAsXml (same error occurs when referencing)
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
This error displayed if string.substring(int startIndex, int length)'s length value is minus...
but i don't know why i get this error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我解决了问题...
我没有复制fldtypes_xxxx.xml信息。
所以当代码尝试从 xml 读取一些信息时,会抛出异常......
I solved the problem...
I didn't copy the fldtypes_xxxx.xml information.
so when the code try to read some information from the xml, exception is thrown...