Web Reference vs. Service Reference

C

cj2

I wrote a web service in VB2008. I then wrote a windows app that calls
it. I added the web service as a service reference. I ran the program
in debug mode and things worked fine. I then changed to release mode
created the exe and ran that and it gave the following error:

System.InvalidOperationException was unhandled
Message="Could not find default endpoint element that references
contract 'MyValWebService.MyValidationSoap' in the ServiceModel client
configuration section. This might be because no configuration file was
found for your application, or because no endpoint element matching this
contract could be found in the client element."
Source="System.ServiceModel"
StackTrace:
at
System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint
serviceEndpoint, String configurationName)
at System.ServiceModel.ChannelFactory.ApplyConfiguration(String
configurationName)
at System.ServiceModel.ChannelFactory.InitializeEndpoint(String
configurationName, EndpointAddress address)
at System.ServiceModel.ChannelFactory`1..ctor(String
endpointConfigurationName, EndpointAddress remoteAddress)
at System.ServiceModel.EndpointTrait`1.CreateSimplexFactory()
at System.ServiceModel.EndpointTrait`1.CreateChannelFactory()
at
System.ServiceModel.ClientBase`1.CreateChannelFactoryRef(EndpointTrait`1
endpointTrait)
at System.ServiceModel.ClientBase`1.InitializeChannelFactoryRef()
at System.ServiceModel.ClientBase`1..ctor()
at RadIpVal.Module1.SessionClass.ThreadMain() in C:\Documents
and Settings\cj.My\My Documents\Visual Studio
2008\Projects\RadIpVal\RadIpVal\Module1.vb:line 17
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode
code, CleanupCode backoutCode, Object userData)
at
System.Threading.ExecutionContext.RunInternal(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:


Just as a test. I deleted the service reference and added it as a web
reference and now it will work in release mode.

Why?
 
C

Cor Ligthert[MVP]

Hi cj

Because a webservice is to a (windows) service as an apple and a peer

Cor
 
C

Colbert Zhou [MSFT]

Hello Chris,

I test in my side but do not see the issue you described.

1. Create a WebService using VB.NET in VS 2008,
<WebMethod()> _
Public Function HelloWorld() As String
Return "Hello World"
End Function

2. Create a Windows Form application and use the Add Service Reference
dialog to add the running web service.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim client As ServiceReference1.Service1SoapClient = New
ServiceReference1.Service1SoapClient()
Me.Text = client.HelloWorld()
End Sub

3. Change the Windows Form application to release mode, compile and run. It
all works fine.

I think this problem can be related to the how we implement the web
service. So,

1. If you use a simple web service as I post, do you still encounter this
problem
2. If the simple one works, would you mind sharing your codes, so I can do
future investigation in my side.


Regards,
Colbert
Microsoft Newsgroup Online Support
 
C

cj2

Colbert,

Thanks for looking into the problem. Since for whatever reason it works
adding it to my windows form as a web service I think I'll just leave it
that way.

Thanks again,
Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top