0
votes

I'm creating a WCF service that will be used to insert data into a database.

The WCF service runs normally when using functions that are scoped locally to within the interface and class of the service itself, however, it fails to start when I use a class that is in an external DLL.

I made sure that the class in the DLL has all the required attributes, but still can't run the service.

Any ideas?

EDIT: This is the faulty function

  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();
        }
    }

The class DAL_Users comes from a DLL and is marked as a 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>

The error I'm receiving is

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:InternalServiceFaultThe 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.

2
You need to share some sample code. What attributes are you using? What is the error? Your question is way to general to get any help here.SliverNinja - MSFT
@SliverNinja I've added some sample codeKamalSalem
Where is your ServiceContract and what is the error message?SliverNinja - MSFT
@SliverNinja I edited the question and added some more infoKamalSalem

2 Answers

0
votes

Try setting includeExceptionDetailInFaults to true in your web.config so you can see the error message generated when requesting the MEX endpoint.

See this SO post which seems identical to the error you're receiving (HTTP status 400: Bad Request).

0
votes

If you are trying to move your service and service contract to an external assembly, you need to modify your .svc file to point to that assembly.

<%@ ServiceHost Language="C#" Debug="true" Service="FULLASSEMBLYNAMEHERE" %>