18 December 2012

Interesting cause for exception: System.InvalidOperationException: $metadata Web Service method name is not valid.


Interesting cause for exception: System.InvalidOperationException: $metadata Web Service method name is not valid.

While deploying a classic web service to a production server recently, we came across an issue when calling the service from a test web application.  We were able to add a web service reference to our test harness web application with no issues.  The web service would load with no issues in a standard web browser as well by url:


When calling the web method the response would come back with no errors.  We noticed the data was not being saved to the server as expected.  After checking the event viewer on the server we found this error that made no sense to us nor offered much detail:

 System.InvalidOperationException: $metadata Web Service method name is not valid.

After searching the web a bit, we learned this was more so a mask error that covered up the true issue.  After digging around for several days, I attempted to test the service directly in a debug state in the server's browser.

The service responded with:

Could not load file or assembly 'Telerik.OpenAccess, Version=2012.2.816.1, Culture=neutral, PublicKeyToken=7ce17eeaf1d59342' or one of its dependencies. The system cannot find the file specified.

We somehow published a version of the telerik.OpenAccess dll that was different then what the service was looking for.

After re-publishing the service with the correct dll version, the issue completely resolved and the web method started saving data to disk.

Lesson learned, the meta data error that originally prompted our research had no relationship to the real exception.  If you come across this error in the future, debug the service straight against the problematic server's web browser to get the true exception.




No comments: