问题
I'm building a class library that uses a web reference in its data access layer, but much to my dismay, there doesn't seem to be an acceptable way to set the access for the auto-generated proxy classes. By default, they're public
, but I don't want to expose the proxy classes outside the library.
I've found this on MSDN, but all the answers indicate manually altering the proxy classes to set the access modifiers.
Not surprisingly, the proxy classes all have this at the top:
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
So I want to play by the rules and not be concerned with having to remember to check the access modifiers every time I compile the project -- something which can be easily overlooked.
Is there a more "official" way to set the default access modifier on proxy classes generated for a web reference?
EDIT:
I found this article too, which relates to setting the access for service references, but I'm talking about an older-style web reference (if you click the "Advanced" button when adding a service reference then click the "Add Web Reference..." button). The article doesn't address my issue.
For anyone interested, the reason I'm using web services instead of WCF is because I'm working with SQL Server Reporting Services (SSRS) which, maddeningly, has geared all its documentation towards web service calls rather than WCF service references (which appear to exist but are very poorly documented).
来源:https://stackoverflow.com/questions/37303550/add-a-web-reference-to-a-project-but-make-the-auto-generated-proxy-classes-inter