Monotouch and WCF: difference between SVCUTIL.EXE and SLSVCUTIL.EXE and how to avoid unsupported common ChannelFactory?

I am trying again and again to use some WCF services in Monotouch. First approach: Failed to add web link in Monodevelop. It cannot create a link file. Then I tried SVCUTIL.EXE and received an error message that the shared ChannelFactory channel is not available in Monotouch - I suppose because there is no reflection.

Next, I tried SLSVCUTIL.EXE from the Silverlight 3 SDK. This creates namespaces for various services that are different from those created with SVCUTIL.EXE. Since I already have a lot of shell code, I have a lot to change.

The following questions arise:

  • Can I override CreateChannel methods and return custom channels for each service instead of relying on a non-existent universal version, as suggested by the exception that is thrown? This means committing the code generated by SVCUTIL.EXE.
  • How to create a channel in an overridden method? I have only the interfaces of my services. I searched Google and could not find any examples. What does the code that should be written in this method look like?
  • It is completely incomprehensible to me: what is the difference between the two utility utilities?
  • If I fix the problem with the namespace, will the stubs created through the Silverlight utility make my project, or will it also be related to the common channel problem?
  • Why can a Silverlight tool work without dynamically emitting code? What is the difference in the output code and what advantage does the dynamic version have?
  • which version of Silverlight is supported by int MT. Can I use the v4 tool or should it be version 3?
  • Does WCF in MT support streaming, for example, when downloading large files?
+6
source share
1 answer

WCF is a huge beast, and it is very difficult to give general answers to it, too much depends on the details. The general rule is that MonoTouch supports the same WCF set that was sent with Silverlight (even if several additions have been made over time).

I suppose because there is no reflection.

Reflection is available and works with MonoTouch. Reflection.Emit does not , because Apple does not allow JIT code on iOS devices. This may limit some APIs that require code generation at runtime (but this is not a problem if code generation can be executed at compile time).

... This means fixing the code generated by SVCUTIL.EXE ....

Fighting / editing generated code is usually a bad idea (like future maintenance). I suggest you try using slsvcutil.exe before investing too much time in setting up the generated code.

... What does the code that should be written in this method look like?

The full source code for Mono System.ServiceModel and System.ServiceModel.Web is available if you want to provide your own channel (or customize the generated code).

Completely unclear to me: what is the difference between the two utility utilities?

The SL prefix, in slsvcutil.exe , is for Silverlight. Microsoft has made this code generation tool that will only use the WCF subset available in Silverlight. Since this is the same subset supported by MonoTouch, this is the best tool.

If I fix the namespace problem, will the stubs created with the Silverlight utility make my project, or will it also have problems with the shared channel?

It should work. The way people use (an affordable subset of) WCF with MonoTouch today. If there is a problem with this (subset / tool), you can fill out a bug report (with a test case), and we take a look at that.

+5
source

Source: https://habr.com/ru/post/902420/


All Articles