metadata issue in app.config

Feb 12 2009 9:04 PM
Hello, I am writing a prototype application using WCF, which has proved to be a REAL challenge.
Basically I have worked through my c# code, and that is looking fine, but I keep having issues with the configuration (masses of errors I have no hope in debugging).

Below is my third attempt (cut right back to the barest essentials), now when I run the service a message comes up "WCF Service Host cannot find any service metadata. This may cause the client application to run improperly. Please check that metadata is enabled. Do you want to exit?"

NOTE: the app.config file is generated so I am not sure what can be wrong with it... (I have tried remove all the namespaces just incase they were wrong (as I added them later), no effect.

<app.config>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.web>
    <compilation debug="true" />
  </system.web> 
  <system.serviceModel>
    <services>
      <service behaviorConfiguration="MOE.PaHekoService.PahekoAppListBehavior"
        name="MOE.PaHekoService.PahekoAppList">
        <endpoint address="" binding="wsHttpBinding" contract="MOE.PaHekoService.IPahekoAppList">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8731/Design_Time_Addresses/PaHekoService/PahekoAppList/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MOE.PaHekoService.PahekoAppListBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

<IPaHekoApplist.cs>
namespace MOE.PaHekoService
{  
    [ServiceContract]
    public interface IPaHekoAppList
    {
        [OperationContract]
        List<PaHekoAppItem> GetList();
    }
}

<PaHekoAppList.cs>
namespace MOE.PaHekoService
{
    public class PaHekoAppList : IPaHekoAppList
    {

        public List<PaHekoAppItem> GetList()
        {
            try
            {
                string resPath = @System.IO.Path.GetDirectoryName(
                    System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\Resources\\";
                //Execute using LINQ to XML
                List<PaHekoAppItem> menuItems = (from c in XElement.Load(resPath +
                    "\\PaHekoItems.xml").Elements("item")
                                                        select (PaHekoAppItem)new PaHekoAppItem
                                                        {
                                                            acronym = c.Element("acronym").Value,
                                                            title = c.Element("title").Value,
                                                            icon = c.Element("icon").Value,
                                                            pic = new Bitmap(resPath + c.Element("icon").Value)
                                                        }).ToList();
                return menuItems;
            }
            catch
            {
                return new List<PaHekoAppItem>(); //Return an empty list
            }
        }

    }
}

<PaHekoData.cs>
namespace MOE.PaHekoData
{
    [DataContract]
    public struct PaHekoAppItem
    {
        [DataMember]
        public string acronym;
        [DataMember]       
        public string title;
        [DataMember]
        public string icon;
        [DataMember]
        public System.Drawing.Bitmap pic;
    }

}

Answers (2)