2012-05-10 26 views
0

我正在創建一個將用於將數據插入數據庫的WCF服務。WCF服務使用來自外部DLL的類時找不到元數據

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> 

我收到的錯誤是

Error: Cannot obtain Metadata from http://localhost:8732/Design_Time_Addresses/ProfileService/Service1/mex If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI: http://localhost:8732/Design_Time_Addresses/ProfileService/Service1/mex Metadata contains a reference that cannot be resolved: 'http://localhost:8732/Design_Time_Addresses/ProfileService/Service1/mex'. Receivera:InternalServiceFault The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.HTTP GET Error URI: http://localhost:8732/Design_Time_Addresses/ProfileService/Service1/mex There was an error downloading 'http://localhost:8732/Design_Time_Addresses/ProfileService/Service1/mex'. The request failed with HTTP status 400: Bad Request.

+1

您需要分享一些示例代碼。你使用什麼屬性?什麼是錯誤?你的問題是一般的方式來獲得任何幫助。 – SliverNinja

+0

@SliverNinja我已經添加了一些示例代碼 – KamalSalem

+0

哪裏是你的['ServiceContract'(http://msdn.microsoft.com/en-us/library/system.servicemodel.servicecontractattribute.aspx),什麼是錯誤訊息? – SliverNinja

回答

0

如果你想你的服務和服務合同轉移到外部組件,您需要修改.svc文件指向該程序集。

<%@ ServiceHost Language="C#" Debug="true" Service="FULLASSEMBLYNAMEHERE" %> 
相關問題