问题
I'm trying to remove all service endpoint mexHttpBinding nodes in my Web.Release.config file.
I found this answer:
(I copied from my code file, so it's actually formatted differently than the answer )
<services>
<service>
<endpoint binding="mexHttpBinding"
xdt:Locator="Match(binding)"
xdt:Transform="RemoveAll" />
</service>
</services>
The warning I am receiving is on the <service>
node:
The required attribute 'name' is missing.
Do I need to add an empty string or wildcard ( if there is one ) to the name
attribute of the <service>
node to resolve this warning?
Also, shouldn't the above transform be wrapped with the <system.serviceModel>
node, or no?
回答1:
That's just a validation warning, because your xml is not meeting the validation requirements of the schema. It doesn't really mean anything and transforms are often not valid to the full xml schema because they, by their nature, are often partial definitions. The transformation will still work. Attributes are ignored in the transform unless you specify them as part of the xdt transform conditions.
Yes, you do need the <system.serviceModel>
element.
If you just want the error to go away, you can set service name = to a service name that you have in your project, but it will not affect the transformation, it will still apply to all services because the name will be ignored (unless you put a xdt:locator constraint on the service element with the name property).
It might be confusing though, if other people have to maintain it. It might be better to leave the warning and comment it, or put the name and comment it, either way.
It should be noted that these are only editor warnings. They are not compiler or runtime warnings. They only show up when you have the file open in the editor, and they are only intellisense warnings, so they have no real affect on the quality of your application or build.
回答2:
You need to give a name for the service.
<service name="serviceName">
Need to be envolved: <system.serviceModel>
来源:https://stackoverflow.com/questions/26808096/why-am-i-receiving-the-required-attribute-name-is-missing-warning-in-my-web-re