TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
L A
NA
170
171.5k
WCF service throws 'InvalidOperationException'
Jan 31 2018 2:35 PM
Hi, i was trying to create basic WCF service and access it.
WCF Appl - ISampleService.cs
using
System.ServiceModel;
namespace
MultipleSeviceContractAppl
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "ISampleService" in both code and config file together.
[ServiceContract]
public
interface
ISampleService
{
[OperationContract]
string
DoWork();
}
}
WCF Appl -
SampleService.cs
namespace
MultipleSeviceContractAppl
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "SampleService" in both code and config file together.
public
class
SampleService : ISampleService
{
public
string
DoWork()
{
return
"Message from WCFservice"
;
}
}
}
WCF Appl -
App.config
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
configuration
>
<
system.serviceModel
>
<
behaviors
>
<
serviceBehaviors
>
<
behavior
name
=
"mexBehaviour"
>
<
serviceMetadata
httpGetEnabled
=
"false"
/>
<
serviceDebug
includeExceptionDetailInFaults
=
"false"
/>
</
behavior
>
</
serviceBehaviors
>
</
behaviors
>
<
services
>
<
service
name
=
"MultipleSeviceContractAppl.SampleService"
behaviorConfiguration
=
"mexBehaviour"
>
<
endpoint
address
=
"SampleService"
binding
=
"netTcpBinding"
contract
=
"MultipleSeviceContractAppl.ISampleService"
>
</
endpoint
>
<
host
>
<
baseAddresses
>
<
add
baseAddress
=
"http://localhost:8733/"
/>
<!--For metadata exchange-->
<
add
baseAddress
=
"net.tcp://localhost:8737/"
/>
<!--Endpoint, netTCP binding-->
</
baseAddresses
>
</
host
>
</
service
>
</
services
>
</
system.serviceModel
>
</
configuration
>
Console - Host WCF Appl
Added service refrence to
ServiceModel
added
using System.ServiceModel; in program.cs file.
using
System;
using
System.ServiceModel;
namespace
ConsumeWCFApplicationAppl
{
class
Program
{
static
void
Main()
{
using
(ServiceHost host =
new
ServiceHost(
typeof
(MultipleSeviceContractAppl.SampleService)))
{
host.Open();
Console.WriteLine(
"Host started @"
+ DateTime.Now.ToString());
Console.ReadKey();
}
}
}
}
On host application at line # 11, following exception was thrown.
An unhandled exception of type 'System.InvalidOperationException' occurred in System.ServiceModel.dll
Additional information: Service 'MultipleSeviceContractAppl.SampleService' has zero application
(non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.
Help me to figure out my mistake.
Thanks
Reply
Answers (
0
)
can't alter .title.title-center.header-thing?
cannot access wcf service hosted in iis