c# - Entity Framework Model With Children in WCF Service works only once -


to start off explaining, have model called vitalsign , 1 called vitalsignvalues.

in vitalsign model have code:

[foreignkey("idvitalsign")] public virtual icollection<vitalsignvalue> vitalsignvalues { get; set; } 

in vitalsignvalue model:

public guid idvitalsign { get; set; } 

and got default manager basic functions getall(), ...

the project contains multiple web services , work fine, except 1 (vitalsignservice). when run service, wcf test client , test getall function, works.

the problem getall function works once, when try call function again error:

an error occurred while receiving http response http://localhost/webservice/vitalsignservice.svc. due service endpoint binding not using http protocol. due http request context being aborted server (possibly due service shutting down). see server logs more details.

i tried check trace logs, reason information gives me is:

asp.net hosted compilation

appdomain unloading

here error log (although doesn't contain information me)

server stack trace: @ system.servicemodel.channels.httpchannelutilities.processgetresponsewebexception(webexception webexception, httpwebrequest request, httpabortreason abortreason) @ system.servicemodel.channels.httpchannelfactory`1.httprequestchannel.httpchannelrequest.waitforreply(timespan timeout) @ system.servicemodel.channels.requestchannel.request(message message, timespan timeout) @ system.servicemodel.dispatcher.requestchannelbinder.request(message message, timespan timeout) @ system.servicemodel.channels.servicechannel.call(string action, boolean oneway, proxyoperationruntime operation, object[] ins, object[] outs, timespan timeout) @ system.servicemodel.channels.servicechannelproxy.invokeservice(imethodcallmessage methodcall, proxyoperationruntime operation) @ system.servicemodel.channels.servicechannelproxy.invoke(imessage message)

exception rethrown @ [0]: @ system.runtime.remoting.proxies.realproxy.handlereturnmessage(imessage reqmsg, imessage retmsg) @ system.runtime.remoting.proxies.realproxy.privateinvoke(messagedata& msgdata, int32 type) @ ivitalsignservice.getallvitalsigns() @ vitalsignserviceclient.getallvitalsigns()

inner exception: underlying connection closed: unexpected error occurred on receive. @ system.net.httpwebrequest.getresponse() @ system.servicemodel.channels.httpchannelfactory`1.httprequestchannel.httpchannelrequest.waitforreply(timespan timeout)

inner exception: unable read data transport connection: existing connection forcibly closed remote host. @ system.net.sockets.networkstream.read(byte[] buffer, int32 offset, int32 size) @ system.net.pooledstream.read(byte[] buffer, int32 offset, int32 size) @ system.net.connection.syncread(httpwebrequest request, boolean userretrievedstream, boolean proberead)

inner exception: existing connection forcibly closed remote host @ system.net.sockets.socket.receive(byte[] buffer, int32 offset, int32 size, socketflags socketflags) @ system.net.sockets.networkstream.read(byte[] buffer, int32 offset, int32 size)

edit:

here more information:

in application, call function:

var client = new vitalsignserviceclient(); _vitalsigns = client.getallvitalsignswithvalues().tolist(); client.close(); 

inside of service, got function:

public icollection<vitalsign> getallvitalsignswithvalues() {     return _vitalsignmanager.getall("vitalsignvalues"); } 

in generic manager, happens:

public icollection<tobject> getall(params string[] navigationproperties) {     var query = context.set<tobject>().asqueryable();     foreach (string navigationproperty in navigationproperties)     query = query.include(navigationproperty);     var list = query.tolist<tobject>();     return list; } 

when try find problem through debugging, go service, generic manager , vitalsigns, it's moment client retrieves data web service error occurs , fails.

also remember of works (but 1 out of 10 times, when server refreshed or something)

solved: removed "virtual" in front of ilist

i don't way you're closing/disposing wcf proxies , ef contexts. looking trouble there. "using" below. recommend don't use static ef context. again looking trouble doing this. (linqtosql declare , instantiate datacontext best practice?). third, know it's tempting make generic repository ends being more work it's worth. testing, performance , maintainability purposes, make api calls specific.

try:

using(var client = new vitalsignserviceclient() {     _vitalsigns = client.getallvitalsignswithvalues().tolist(); }  public icollection<vitalsign> getallvitalsigns() {     using(ctx = new yourcontext())     {        // stuff     } } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -