문제

I am developing WCF project under DotNet4 environment. WCF is new to me. I am surprised that it is required to add each new service to web.config. To avoid we accidentally deploy web.config with DEV database connection string to production server, is there any way that I can either add new services to an external configure file or "register" service inside each new service itself?

I did some researches. The more I read, the more I confused. It is possible to create WCF web service without changing web.config at all?

Thanks for any help in advanced.

도움이 되었습니까?

해결책

I am not expert in WCF, but from what I read, you have 2 problem:

  1. you don't want the development connection string to be on the production config file: to solve this, there is something called config transformation which essentialy change config setting when compiling your project. read:

    http://www.codeproject.com/Tips/559849/Transform-Web-Config-when-Deploying-a-Web-Applicat

    http://www.asp.net/web-forms/tutorials/deployment/visual-studio-web-deployment/web-config-transformations

    edit: above work for website application, if you need wcf to have similar function, checkout http://www.hanselman.com/blog/SlowCheetahWebconfigTransformationSyntaxNowGeneralizedForAnyXMLConfigurationFile.aspx

  2. Is it possible to dfine service programatically? have a look: http://msdn.microsoft.com/en-us/library/hh205277(v=vs.110).aspx

    How to programatically create a WCF service and its metadata on the same URL

    How can I register a WCF service programmatically within an IIS environment

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top