Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
0 like 0 dislike
1k views
in .Net Framework by 63 69 85

I am trying to migrate a legacy system to a new project with .Net framework 4.8, I added the web service to my newly created project, and when calling a specific function in this web service that requires three parameters. But in the old code, it passes an object instead of three parameters, and when budling the solution I get the belowbug:

There is no argument given that corresponds to the required formal parameter 'parameter1', of 'function1(parameter1)'

I tried to pass the required parameters but it needs to change the original datatype of the returned value, and I can't do that. How can I fix this error?


1 Answer

1 like 0 dislike
by 152 169 345
selected by
 
Best answer

To can customize the parameters sent using a SOAP message, and pass an object instead of the required parameters, you have to generate A Message Contract that is used to control the structure of a message body and the serialization process.

How to Generate Message Contracts in Web Service Reference?

In your case, if you have already added your web service reference, so you have to update it and check "Always generate message contracts" option as the following:

  1. In Solutions Explorer, Right click on Service Reference.
  2. select "Configure Service Reference".
  3. Below Data Type, Check "Always generate message contracts".
    Always generate message contracts
  4. Try now to build your solution, and you will note that this error "There is no argument given that corresponds to the required formal parameter" is gone!
If you don’t ask, the answer is always NO!
...