ich neue WCF-Programmierung, habe ich Reihe von Ersten Schritten Tutorials von folgendem Link gefolgtWCF mit Visual Studio 2012
http://msdn.microsoft.com/en-us/library/ms734712.aspx
I Service in Konsolenanwendung gehostet habe, aber wenn ich einen Client zu erstellen versucht und Ich habe versucht, Service-Referenz hinzuzufügen. Ich habe die folgenden Ausnahmen.
There was an error downloading 'http: localhost:8000/GettingStarted/mex/_vti_bin/ListData.svc/$metadata'. The request failed with HTTP status 405: Method Not Allowed. Metadata contains a reference that cannot be resolved: 'http: localhost:8000/GettingStarted/mex'. There was no endpoint listening at http: localhost:8000/GettingStarted/mex that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. The remote server returned an error: (404) Not Found. If the service is defined in the current solution, try building the solution and adding the service reference again.
Code Anwendung von Hosting
class Program
{
static void Main(string[] args)
{
// Step 1 Create a URI to serve as the base address.
Uri baseAddress =
new Uri("http://localhost:8000/GettingStarted/");
// Step 2 Create a ServiceHost instance
ServiceHost selfHost =
new ServiceHost(typeof(CalculatorService), baseAddress);
try
{
// Step 3 Add a service endpoint.
selfHost.AddServiceEndpoint(typeof(ICalculator),
new WSHttpBinding(),
"CalculatorService");
// Step 4 Enable metadata exchange.
var smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
selfHost.Description.Behaviors.Add(smb);
// Step 5 Start the service.
selfHost.Open();
Console.WriteLine("The service is ready.");
Console.WriteLine("Press <ENTER> to terminate.");
Console.WriteLine();
Console.ReadLine();
// Close the ServiceHostBase to shutdown.
selfHost.Close();
}
catch (CommunicationException ce)
{
Console.WriteLine("exception: {0}", ce.Message);
selfHost.Abort();
}
}
}
Jetzt bin ich nicht in der Lage, herauszufinden, was das Problem ist. Ich benutze Visual Studio 2012 und .net Plattform 4.5.
Erstens konnten Sie erfolgreich einen Dienst hosten? Können Sie die Ausgabe Ihrer Konsolenanwendung freigeben? – Praburaj