F # interactive solution F # and WCF

Try running this in F # interactive:

#r "System.ServiceModel" #r "System.Runtime.Serialization" open System.ServiceModel [<ServiceContract>] type IWCF = [<OperationContract>] abstract Ping: float -> unit type WCF () = interface IWCF with member o.Ping a = printfn "Hello, %g" a let svh = new ServiceHost (typeof<WCF>) 

You are likely to succeed. Try to make a new decision.

Link:

  • System.Runtime.Serialization
  • System.ServiceModel

Paste the following code in Program.fs :

 open System.ServiceModel [<ServiceContract>] type IWCF = [<OperationContract>] abstract Ping: float -> unit type WCF () = interface IWCF with member o.Ping a = printfn "Hello, %g" a let svh = new ServiceHost (typeof<WCF>) 

And run it. I get the following error:

All parameter names used in the operations that make up the service contract must not be null. Parameter Name: Name

What's wrong?

PS: I am using Visual Studio 2010 Ultimate SP1

EDIT: just make sure the C # equivalent works fine

+6
source share
2 answers

The problem is that you need to have names for parameters in WCF-Operations.

Here is the solution to get named parameters there (named it a just like you) - about why it works in F # -Interactive? There is no clue, maybe it puts some standard names for parameters. The syntax is a bit strange, but you can define names for parameters in F #, try:

 [<ServiceContract>] type IWCF = [<OperationContract>] abstract member Ping: a:float -> unit 

NOTE. I don’t know if you need a member , but I just checked some of my files and placed them there. I don’t have a compiler around the ATM, so I’ll let it sit there if you really need it (but I don’t think so)

+7
source

I know this problem was marked as an answer, but I came across the same exception message, for a completely different reason. I am just sending a message if someone else is experiencing the same problem for the same reason as mine.

In my case, I used dotNET_Reactor to obfuscate my service.exe with the -exclude_types 1 -necrobit 1 -mapping_file 1 'flags in addition to -file and -targetfile.

I did not track the actual “why,” it did not work, but removing obfuscation helped. It was very unpleasant to know that everything works with visual studio, but when the service started, when installing the application (which was launched by the build server) on the same computer was not.

Bjørnar sundsbø

+1
source

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


All Articles