質問

SharePoint 2010のVisual Webパーツを開発しています。このWebパートは、AJAXを介してデータを取得する必要があります。だから私はhttpハンドラー + jqueryソリューションに投稿しました ここ.

しかし、ハンドラーにアクセスしようとすると問題が発生しています。有名な.NETエラーページを取得します:

'/'アプリケーションのサーバーエラー。ランタイムエラー説明:サーバーでアプリケーションエラーが発生しました。このアプリケーションの現在のカスタムエラー設定により、アプリケーションエラーの詳細がリモートで表示されなくなります(セキュリティ上の理由で)。ただし、ローカルサーバーマシンで実行されているブラウザによって表示される可能性があります。

詳細:この特定のエラーメッセージの詳細をリモートマシンで表示できるようにするには、現在のWebアプリケーションのルートディレクトリにある「web.config」構成ファイル内にタグを作成してください。このタグには、「モード」属性が「オフ」に設定されている必要があります。

注:表示されている現在のエラーページは、アプリケーションの構成タグの「defaultredirect」属性を変更してカスタムエラーページURLを指すことにより、カスタムエラーページに置き換えることができます。

そこで、サーバーのイベントビューアーをチェックして、エラーの詳細を確認しました。これがそれを引き起こしているものです:

Event code: 3006 
Event message: A parser error has occurred. 
Event time: 8/4/2011 2:08:17 PM 
Event time (UTC): 8/4/2011 6:08:17 PM 
Event ID: 71c80726be98453ab77a7c1d474cbf7c 
Event sequence: 5 
Event occurrence: 2 
Event detail code: 0 

Process information: 
    Process ID: 6200 
    Process name: w3wp.exe 
    Account name: NT AUTHORITY\NETWORK SERVICE 

Exception information: 
    Exception type: HttpParseException 
    Exception message: Could not create type 'MyNamespace.MyHandler'. 

Request information: 
    Request URL: http://mysharepointurl/_layouts/MyNamespace/MyHandler.ashx 
    Request path: /_layouts/MyNamespace/MyHandler.ashx 
    User host address: xxx.xxx.xxx.xxx
    User:  
    Is authenticated: False 
    Authentication Type:  
    Thread account name: NT AUTHORITY\NETWORK SERVICE 

Thread information: 
    Thread ID: 11 
    Thread account name: NT AUTHORITY\NETWORK SERVICE 
    Is impersonating: True 
    Stack trace:    at System.Web.UI.SimpleWebHandlerParser.GetType(String typeName)
   at System.Web.UI.SimpleWebHandlerParser.GetTypeToCache(Assembly builtAssembly)
   at System.Web.Compilation.SimpleHandlerBuildProvider.GetGeneratedType(CompilerResults results)
   at System.Web.Compilation.BuildProvider.CreateBuildResult(CompilerResults results)
   at System.Web.Compilation.BuildProvider.GetBuildResult(CompilerResults results)
   at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)
   at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
   at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
   at System.Web.UI.SimpleHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
   at System.Web.UI.SimpleHandlerFactory.GetHandler(HttpContext context, String requestType, String virtualPath, String path)
   at System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

これはmyhandler.ashxです

<%@ WebHandler Language="C#" Class="MyNamespace.MyHandler" CodeBehind="MyHandler.cs" %>

ご覧のとおり、私は見逃しています Assembly 指令。しかし、私はそれに何を入れるべきかわかりません。 キートトーク、名前などはどこで入手できますか?

役に立ちましたか?

解決

Visual Studioコマンドプロンプトを開くことになりました。私のWebパーツのビン/リリースフォルダーに移動し、 sn -t トークンを取得するために私のDLLにコマンド!

他のヒント

Visual Studioでは、利用可能なSharePointトークンを愛することを学びます。それらの詳細をこちらをご覧ください: http://www.andrewconnell.com/blog/archive/2009/12/03/sharepoint-2010-dev-tidbit-use-the-tokens-in-visual.aspx

私は今日、別の.ashxファイルと.csファイルで同じことをしました、そしてそれは私のために働きます。同じエラーが発生しましたが、クラス名の間違いを犯したことに気付きました。これが私のコードです:

*****DemoHandler.cs********
using System;
using System.Web;
using Microsoft.SharePoint;

namespace CustomHTTPModule
{
    public class DemoHandler : IHttpHandler
    {
        public bool IsReusable
        {
            get { return false; }
        }


        public void ProcessRequest(HttpContext context)
        {
            SPSite siteColl = SPContext.Current.Site;
            SPWeb site = SPContext.Current.Web;
            context.Response.ContentType = "text/plain";
            context.Response.Write("Hello World from " +
                                   site.Title +
                                   " at " +
                                   site.Url);
        }
    }
}


*********DemoHandler.ashx*******************
<%@ Assembly Name="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Assembly Name="CustomHTTPModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9eec5e2ad94ff809" %>
<%@ WebHandler Language="C#"  Class="CustomHTTPModule.DemoHandler" CodeBehind="DemoHandler.cs" %>

私はプロジェクト構造の画像については、以下のブログをご覧ください

展開]をクリックして、customhttpmodule dllをgacに展開し、.ashxをWebアプリの_layoutsに展開する必要があります。http://webappname/sites/sitename/customhttpmodule/demohandler.ashx「私が言及したサイト名であなたにテキストを与えるべきです http://blogs.msdn.com/b/kaevans/archive/2010/08/04/deploying-an-asp-net-httphandler-to-sharepoint-2010.aspx

迅速で汚い方法? GACにアセンブリをドロップし、その上にプロパティを取得します。必要なものができたら、右クリックしてアンインストールできます。

更新(15Jan13):

また、これを支援するためにVisual Studioに外部ツールを追加することもできます(ツール - >外部ツール...):

Title: Get Assembly Name
Command: powershell.exe
Arguments: -command  "[System.Reflection.AssemblyName]::GetAssemblyName(\"$(TargetPath)\").FullName"
Use Output Window: checked

コマンドを実行すると、出力ウィンドウに次のようなものが表示されます。

YourAssemblyName、バージョン= 1.0.0.0、Culture = neutral、publicKeyToken = 9999D8E7777777F66

あなたは強い名前ツールのために同じ種類のことをすることができます:

Title: Get Strong Name Token
Command: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\sn.exe
Arguments: -T $(TargetPath)
Use Output Window: checked

このようなものを表示する出力ウィンドウで:

Microsoft(R).Net Framework Strong Name Utilityバージョン3.5.30729.1 Copyright(c)Microsoft Corporation。全著作権所有。

公開キートークンは9999D8E7777777F66です

ライセンス: CC-BY-SA帰属
所属していません sharepoint.stackexchange
scroll top