6

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?

Community
  • 1
  • 1
Code Maverick
  • 20,171
  • 12
  • 62
  • 114
  • You need to give it whatever name you have in web.config so it knows which service to remove from. – artm Dec 22 '14 at 23:11
  • I've not seen anything in the web that suggests this should be a valid warning. It seems that it's a bug in the Code Analysis of web config transform files. – Code Maverick Dec 30 '14 at 15:26
  • are you talking about the editor intellisense? Or are you talking about an error when you do the actual transform? – Erik Funkenbusch Dec 31 '14 at 22:01
  • @ErikFunkenbusch - It is a warning in Visual Studio 2013. It appears as a warning in the Error list pane and is underlined via intellisense in the editor. – Code Maverick Dec 31 '14 at 22:07

2 Answers2

4

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.

Erik Funkenbusch
  • 92,674
  • 28
  • 195
  • 291
  • Which is my point. It seems that VS should recognize a transform file and not apply those warnings. – Code Maverick Dec 31 '14 at 23:43
  • @CodeMaverick - complaining about what "should be" is pointless... this is "what is". The fact is, there are probably cases where assuming you don't want warnings is also wrong, so MS would get complaints either way. They could maybe add a feature to disable warnings in the properties of the file, but just how much effort should MS put into something that's really barely an issue. – Erik Funkenbusch Dec 31 '14 at 23:47
  • If people didn't challenge "what is" then change wouldn't ever occur. My point is maybe there should be different validation schemas for transform files, that's all. – Code Maverick Dec 31 '14 at 23:50
  • @CodeMaverick - then I suggest you take it up with Microsoft, rather than asking a question, and then arguing about the valid answer you get to that question. There are several forums in which you can give MS feedback on Visual Studio, such as uservoice. This is not one of those forums. – Erik Funkenbusch Dec 31 '14 at 23:53
  • Either way, your answer is what I'll accept because it explains what happens. Thanks for your input. – Code Maverick Jan 01 '15 at 00:00
-1

You need to give a name for the service.

<service name="serviceName">

Need to be envolved: <system.serviceModel>

  • I have to down vote you. My question clearly shows that I'm trying to remove all mexHttpBinding endpoints for _all_ services, not _one_. – Code Maverick Dec 30 '14 at 23:19
  • @CodeMaverick - adding the name will still remove the endpoints for all services, it's just shutting up the validator because attributes are ignored by the xslt processor by default. So, you downvoted without even trying the solution? – Erik Funkenbusch Dec 31 '14 at 23:43
  • @ErikFunkenbusch It doesn't answer my actual question. I want to get rid of the warning if it's valid. Apparently your answer and my research since posting seem to point to it being a bug due to it applying schema validation when it really shouldn't be. – Code Maverick Dec 31 '14 at 23:46
  • @CodeMaverick - Why do you assume it shouldn't be applying schema validation? Certainly there is validation that should be applied, it's a thorny problem because different people will want different things. And yes, it does answer your question. It removes the warning and still gives you the transform output you want, so I don't see why you are complaining. – Erik Funkenbusch Dec 31 '14 at 23:49
  • Because it's a hack really. I have many different services. There's no way I'm going to just throw one in there. This is what brought the question up to begin with. – Code Maverick Dec 31 '14 at 23:53
  • @CodeMaverick - then you're going to have to live with the warning, because there is no other way to disable it. – Erik Funkenbusch Dec 31 '14 at 23:55