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

编辑2:

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由于内部错误,服务器无法处理请求。有关错误的详细信息,请在服务器上打开 IncludeExceptionDetailInFaults(来自 ServiceBehaviorAttribute 或来自 <serviceDebug> 配置行为)以便将异常信息发送回客户端,或者根据 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:错误请求。

4

2 回答 2

0

尝试在您的设置中设置includeExceptionDetailInFaults为,以便您可以看到请求 MEX 端点时生成的错误消息。trueweb.config

请参阅此 SO 帖子,该帖子似乎与您收到的错误相同(HTTP status 400: Bad Request)。

于 2012-05-10T13:18:52.127 回答
0

如果您尝试将服务和服务合同移至外部程序集,则需要修改 .svc 文件以指向该程序集。

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