türkçe c# püf noktaları.

Friday, May 04, 2007

wcf den aldığım diğer exceptionlar.

client ı kullanırken ara verdiğimde tekrar bi işlem yaptığımda çatlıodu ona basit bir check fonksiyonu yazmakda fayda var sakın habire WCFClient cli=new WCFClient(); gibi şeyler yapmayın garip hatalar olabilio aşşağıda örnekleri.

bu arada server'dan client a Bitmap yollamanız gerekirse ve bunlar büyük olursa aşağıdaki gibi app.config dosyanıza readerQuotas maxArrayLength bölgesine büyüüük rakamlar dayıyorsunuz. velhasıl 2 veya 3 günde epey becerikli server/client naneniz olabiliyor.
<bindings>
<wsHttpBinding>
<binding name="TransactionalWS" transactionFlow="true" sendTimeout="00:05:00" maxReceivedMessageSize="2147483647">
<readerQuotas maxArrayLength="2147483647"/>
<reliableSession enabled="True" />
</binding>
</wsHttpBinding>
</bindings>

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:patientInfo. The InnerException message was 'There was an error deserializing the object of type ViCentEasy.PatientInfo. The maximum array length quota (16384) has been exceeded while reading XML data. This quota may be increased by changing the MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 709201.'. Please see InnerException for more details.


The maximum retry count has been exceeded with no response from the remote endpoint. The reliable session was faulted. This is often an indication that the remote endpoint is no longer available.

Thursday, May 03, 2007

WCF large return issues

wcf kullanırken bazen serverdan 3067 elemanlı bir array göndermeniz gerekebilir bu elemanlarda sizin oluşturduğunuz bir class dan oluşuyor ise biraz büyükçe gelebilir o zaman abuk subuk hatalara maruz kalırsınız.
1. si
"The request channel timed out while waiting for a reply after 00:00:59.4062500. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout."

yani diyorki server zamanında veremedi. halbuki verdi ikiside aynı makinede gözümle görüom yahu. sonra timeout u nasıl artırırsınız şöyle: sendTimeout="00:05:00" yani 5dk bekle dioz clienta app.configde. oda beklemeyi insan olmayı bilio bu seferde başka abuk bir exception
2. si
{"The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element."}
top olasın wcf insanmısın sen diyip bakınıoz ve şunuda app.config e eklememiz gerektiğini görüoz: maxReceivedMessageSize="5000000"
aha bundan sonra 3sn de alıp işine devam edio demekki derdi timeout değil size mıymış bende bilmiom ama bu eblek exceptionlarda olmasa hayatın heyecanı nerede dimi :D

bu arada verdiğim tagların yerini bulmasıda mesele olabilir özellikle svcutil.exe den config aldıysanız eşşek kadar config çıkarıo. o sebeple yukardaki tagların asıl olması gerektiği gibi olan app.config aşşağıdadır.
app.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<client>
<endpoint
address="http://localhost:8000/"
binding="wsHttpBinding"
bindingConfiguration="TransactionalWS"
contract="IViCent"
/>
</client>
<bindings>
<wsHttpBinding>
<binding name="TransactionalWS" transactionFlow="true" sendTimeout="00:05:00" maxReceivedMessageSize="5000000" >
<reliableSession enabled="True" />
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
</configuration>

umarım birinin işine yarar.