erum mirza

erum mirza

  • NA
  • 121
  • 0

WCF Silverlight error

Sep 17 2010 12:58 AM

i m getting an error
The contract name 'IMetadataExchange' could not be found in the list of contracts implemented by the service Service1.  Add a ServiceMetadataBehavior to the configuration file or to the ServiceHost directly to enable support for this contract.
 
here is the chunk of code
 
<?
xml version="1.0"?>
<
configuration>
<
configSections>
<
sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<
sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<
section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
<
sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<
section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
<
section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
<
section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
<
section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
</
sectionGroup>
</
sectionGroup>
</
sectionGroup>
</
configSections>
<
appSettings/>
<
connectionStrings>
<
add name="VotingConnectionString" connectionString="Data Source=IRAM-PC;Initial Catalog=Voting;Integrated Security=True"
providerName="System.Data.SqlClient" />
</
connectionStrings>
<
system.web>
<!--

Set compilation debug="true" to insert debugging symbols into the compiled page. Because this affects performance, set this value to true only during development.
-->
<
compilation debug="false">
<
assemblies>
<
add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<
add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<
add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<
add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</
assemblies>
</
compilation>
<!--

The <authentication> section enables configuration of the security authentication mode used by ASP.NET to identify an incoming user.
-->
<
authentication mode="Windows" />
<!--

The <customErrors> section enables configuration of what to do if/when an unhandled error occurs during the execution of a request. Specifically, it enables developers to configure html error pages to be displayed in place of a error stack trace. <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm"> <error statusCode="403" redirect="NoAccess.htm" /> <error statusCode="404" redirect="FileNotFound.htm" /> </customErrors>
-->
<
pages>
<
controls>
<
add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<
add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</
controls>
</
pages>
<
httpHandlers>
<
remove verb="*" path="*.asmx"/>
<
add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<
add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<
add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
</
httpHandlers>
<
httpModules>
<
add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</
httpModules>
</
system.web>
<
system.codedom>
<
compilers>
<
compiler language="c#;cs;csharp" extension=".cs" warningLevel="4"
type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<
providerOption name="CompilerVersion" value="v3.5"/>
<
providerOption name="WarnAsError" value="false"/>
</
compiler>
</
compilers>
</
system.codedom>
<!--

The system.webServer section is required for running ASP.NET AJAX under Internet Information Services 7.0. It is not necessary for previous version of IIS.
-->
<
system.webServer>
<
validation validateIntegratedModeConfiguration="false"/>
<
modules>
<
remove name="ScriptModule" />
<
add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</
modules>
<
handlers>
<
remove name="WebServiceHandlerFactory-Integrated"/>
<
remove name="ScriptHandlerFactory" />
<
remove name="ScriptHandlerFactoryAppServices" />
<
remove name="ScriptResource" />
<
add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode"
type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<
add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode"
type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<
add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</
handlers>
</
system.webServer>
<
runtime>
<
assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<
dependentAssembly>
<
assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
<
bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
</
dependentAssembly>
<
dependentAssembly>
<
assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
<
bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
</
dependentAssembly>
</
assemblyBinding>
</
runtime>
<
system.serviceModel>
<
bindings>
<
customBinding>
<
binding name="customBinding0">
<
binaryMessageEncoding />
<
httpTransport>
<
extendedProtectionPolicy policyEnforcement="Never" />
</
httpTransport>
</
binding>
</
customBinding>
</
bindings>
<
behaviors>
<
endpointBehaviors>
<
behavior name="VotingPanel2.Web.Service1AspNetAjaxBehavior">
<
enableWebScript />
</
behavior>
</
endpointBehaviors>
<
serviceBehaviors>
<
behavior name="VotingPanel2.Web.Service2Behavior">
<
serviceMetadata httpGetEnabled="true" />
<
serviceDebug includeExceptionDetailInFaults="false" />
</
behavior>
</
serviceBehaviors>
</
behaviors>
<
serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<
services>
<
service name="VotingPanel2.Web.Service1">
<
endpoint address="" behaviorConfiguration="VotingPanel2.Web.Service1AspNetAjaxBehavior"
binding="webHttpBinding" contract="VotingPanel2.Web.Iservice1" />
<
endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
</
service>
</
services>



</
system.serviceModel>
</
configuration>
 
using System.Data;
using System.Data.SqlClient;
using System;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.Collections.Generic;
using System.Text;
namespace VotingPanel2.Web
{
[
ServiceContract]
public interface Iservice1
{
[
OperationContract]
List<Vote> GetChartData();
[
OperationContract]
void Insertdata(String vote, DateTime dt);
[
OperationContract]
void GetData();
}
[
AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service1 : Iservice1
{

SqlConnection Conn;
SqlCommand Cmd;

# region
Iservice1 members
//[OperationContract]
public List<Vote> GetChartData()
{
DataClasses1DataContext db = new DataClasses1DataContext();
var query = from c in db.Votes select c;
return query.Take(10).ToList();
}

# endregion


public void Insertdata(String vote, DateTime dt)
{
Conn =
new SqlConnection("Data Source=IRAM-PC;Initial Catalog=Voting;User-Id=sa;Password=sa;Integrated Security=SSPI");
Cmd =
new SqlCommand();
Conn.Open();
Cmd.Connection = Conn;
Cmd.CommandText =
"insert into votes values ('" + vote + "', '" + dt + "' )";

int ins = Cmd.ExecuteNonQuery();
//if (ins > 0)
//{
// Inserted = true;
//}
Conn.Close();
}
public void GetData()
{
bool Inserted = false;
Conn =
new SqlConnection("Data Source=IRAM-PC;Initial Catalog=Voting;User-id=sa;Password=sa;Integrated Security=SSPI");
Cmd =
new SqlCommand();
Conn.Open();
Cmd.Connection = Conn;
Cmd.CommandText =
"SELECT votingtext, COUNT(Votingtext) AS count FROM votes group by Votingtext";

int ins = Cmd.ExecuteNonQuery();
if (ins > 0)
{
Inserted =
true;
}
Conn.Close();
//return Inserted;
}
}
}