1

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) の長さの値がマイナスの場合に表示されます...しかし、なぜこのエラーが発生するのかわかりません。

4

1 に答える 1

1

問題を解決しました... fldtypes_xxxx.xml の情報をコピーしていませんでした。そのため、コードがxmlから情報を読み取ろうとすると、例外がスローされます...

于 2010-07-09T03:09:17.343 に答える