开发者

problem breaking up one SharePoint project into pieces

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 fAlw开发者_运维百科aysCopy) +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.


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...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜