0

データベースにデータを挿入するために使用される WCF サービスを作成しています。

WCF サービスは、サービス自体のインターフェイスおよびクラス内でローカルにスコープされている関数を使用すると正常に実行されますが、外部 DLL にあるクラスを使用すると開始に失敗します。

DLL 内のクラスに必要な属性がすべて含まれていることを確認しましたが、それでもサービスを実行できません。

何か案は?

編集:これは欠陥のある機能です

  public Dal_Users createProfile(DateTime dateOfBirth, string email, string firstname, bool genderIsMale, string lastname, string mphoneno, string nickname, string password, string pictureURL)
    {
        try
        {
            //generate new user object
            /////////////////////////start user metadata/////////////////////////////////////////
            Dal_Users newUser = new Dal_Users();
            newUser.DateOfBirth = dateOfBirth;
            newUser.Email = email;
            newUser.FirstName = firstname;
            newUser.GenderIsMale = genderIsMale;
            newUser.LastName = lastname;
            newUser.MPhoneNo = mphoneno;
            newUser.NickName = nickname;
            newUser.Password = password;
            newUser.ProfilePicture = pictureURL;
            //////////////////////////////end user metadata///////////////////////////////////////


            //insert user in database, call updateUsers without an ID
            newUser.UpdateUsers();

            return newUser;
        }
        catch (Exception ex)
        {
            return new Dal_Users();
        }
    }

クラス DAL_Users は DLL に由来し、DataContract

/// <summary>
/// this is the data access class for the table Users
/// </summary>
[DataContract]
public class Dal_Users

EDIT2:

My app.config looks like this 
 <system.serviceModel>
    <services>
      <service name="ProfileService.ProfileMgr">
        <endpoint address="" binding="wsHttpBinding" contract="ProfileService.IProfileMgr">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8732/Design_Time_Addresses/ProfileService/Service1/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="True"/>
          <!-- To receive exception details in faults for debugging purposes, 
          set the value below to true.  Set to false before deployment 
          to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

私が受け取っているエラーは

エラー: http://localhost:8732/Design_Time_Addresses/ProfileService/Service1/mexからメタデータを取得できませんこれがアクセス権を持つ Windows (R) Communication Foundation サービスである場合は、指定されたアドレスでのメタデータ公開が有効になっていることを確認してください. メタデータの公開を有効にする方法については、http: //go.microsoft.com/fwlink/ ?LinkId=65455.WS-Metadata Exchange Error URI: http://localhost:8732/Design_Time_Addresses/ProfileService/Service1にある MSDN ドキュメントを参照してください。 /mex メタデータには、解決できない参照が含まれています: 'http://localhost:8732/Design_Time_Addresses/ProfileService/Service1/mex'。 Receivera:InternalServiceFault内部エラーのため、サーバーは要求を処理できませんでした。エラーの詳細については、サーバーで (ServiceBehaviorAttribute または <serviceDebug> 構成動作のいずれかから) IncludeExceptionDetailInFaults をオンにして、例外情報をクライアントに送り返すか、Microsoft .NET Framework に従ってトレースをオンにします。 3.0 SDK ドキュメントを参照し、サーバー トレース ログを調べます。HTTP GET エラー URI: http://localhost:8732/Design_Time_Addresses/ProfileService/Service1/mex 'http://localhost:8732/Design_Time_Addresses/ProfileService/Service1/メックス」。リクエストは HTTP ステータス 400: Bad Request で失敗しました。

4

2 に答える 2

0

サービスおよびサービス コントラクトを外部アセンブリに移動しようとしている場合は、そのアセンブリを指すように .svc ファイルを変更する必要があります。

<%@ ServiceHost Language="C#" Debug="true" Service="FULLASSEMBLYNAMEHERE" %>
于 2012-05-10T13:10:49.977 に答える
0

MEX エンドポイントを要求するときに生成されるエラー メッセージを確認できるように、 に設定includeExceptionDetailInFaultsしてみてください。trueweb.config

受け取ったエラー ( HTTP status 400: Bad Request )と同じように見えるこの SO 投稿を参照してください。

于 2012-05-10T13:18:52.127 に答える