3

パッチ KB958502 を Visual Studio 2008 に適用し、次の行を含めることで、最終的に Intellisense が JQuery で動作するようになりました。

/// <reference path="JQuery\jquery-1.3.2.js"/>

私の.jsファイルの上部にあります。現在、ScriptManager の ScriptReference 要素によって生成されたクライアント プロキシの JavaScript インテリセンスを取得する方法を見つけようとしています (ここに示すように)。

    <asp:ScriptManager ID="ScriptManager1" runat="Server" EnablePartialRendering="false" AsyncPostBackTimeout="999999">
        <Services>
            <asp:ServiceReference path="../Services/DocLookups.svc" />
        </Services>
    </asp:ScriptManager>

クライアント プロキシは機能しています。つまり、それらを介して呼び出しを行うことはできますが、Intellisense が得られません。

私のサービスは .svc ファイルで定義されています:

<%@ ServiceHost Language="C#" Debug="true" Service="Documents.Services.DocLookups" CodeBehind="~/App_Code/DocLookups.cs" %>

コード ビハインド ファイルは次のようになります。

[ServiceContract(Namespace = "Documents.Services", Name = "DocLookups")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(IncludeExceptionDetailInFaults = true)]
public class DocLookups {
...

このクラスのサンプル メソッドは次のとおりです。

    //Called at the begining of the page to fill in the category list
    [OperationContract]
    public SelectOption[] GetCategoriesForSelectList()
    {
        SelectOption[] Result;
        IDocumentRepository repository = new DocumentEntityRepository(ConnectionString);
        Result = (from cat in repository.GetDocCategories()
                  select new SelectOption(cat.Category_ID.ToString(), cat.CategoryName)).ToArray();
        if (Result.Length > 0)
            Result[0].Selected = true;  //Select first item 
        return Result;
    }

そして、次のように定義されたデータ コントラクトを使用します。

namespace Documents.Services {

[DataContract]
public class SelectOption
{
    //A useful DTO to use when filling a <select> element with options
    public SelectOption(string optionValue, string optionText) {
        OptionValue = optionValue;
        OptionText = optionText;
        Selected = false;
    }
    public SelectOption(string optionValue, string optionText, bool selected) {
        OptionValue = optionValue;
        OptionText = optionText;
        Selected = selected;
    }

    [DataMember]
    public string OptionValue { get; set; }
    [DataMember]
    public string OptionText { get; set; }
    [DataMember]
    public bool Selected { get; set; }
}

}

私の JavaScript ファイルでは、このサービスへの呼び出しは次のようになります。

Documents.Services.DocLookups.GetCategoriesForSelectList(...

しかし、Intellisense が表示されません (たとえば、Documents. と入力しても何も表示されません)。生成されたメソッドまたはメソッドで使用される [DataContract] 型のいずれについても、インテリセンスを取得できません。

これらのプロキシとタイプに対して Intellisense を取得することになっていると思いますが、何が間違っているのかわかりません。ティア。

4

3 に答える 3

4

うまくいき /// <reference path="../Services/DocLookups.svc" /> ませんでしたか?

于 2009-02-26T06:01:54.800 に答える
0

私はこの同じ問題に遭遇し、私の問題を解決する Visual Studio 2008 用の修正プログラムがあることを発見しました:

http://support.microsoft.com/kb/958502

于 2009-04-16T17:07:29.937 に答える
0

追加する必要があることを指摘してくれたスコットに感謝します

///<reference path... 

ライン。どこに文書化されているかはわかりませんが、WCF で生成されたクライアント側プロキシにこれが必要であることを見逃していましたが、JQuery の Intellisense を取得するために同じイディオムが使用されていることを考えると理にかなっています。

記録として、私が最終的に使用しなければならなかった行は、私のプロジェクト構造を考慮して Scott が提案したものとは少し異なっていました。私は試した:

/// <reference path="../Documents/Services/DocLookups.svc" /> 

次に、ファイルを保存し、VS の [編集] メニューから [ Intellisense ... Update JScript Intellisense ... ] を選択しました。

残念ながら、これは機能せず、Intellisense の更新時に次のエラーが発生しました。

Error updating JScript IntelliSense: 
C:\TFSSource\LitigationPortal\Version 1.0\LitigationPortal\Documents\Services\DocLookups.svc:
'Type' is undefined @ 0:0

だから私はある程度の進歩を遂げましたが、まだそこにはいません。

于 2009-02-26T17:31:31.727 に答える