c# - Transform Web.config Hibernate configuration VS 2012 -
i have web.config:
<?xml version="1.0"?> <configuration> <configsections> <section name="hibernate-configuration" type="nhibernate.cfg.configurationsectionhandler, nhibernate" requirepermission="false"/> </configsections> <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> <session-factory> <property name="connection.driver_class">nhibernate.driver.oracleclientdriver</property> <property name="connection.connection_string">{old_connection}</property> <property name="dialect">nhibernate.dialect.oracle10gdialect</property> <property name="proxyfactory.factory_class">nhibernate.bytecode.defaultproxyfactoryfactory, nhibernate</property> <property name="show_sql">false</property> <property name="query.substitutions">true 1, false 0, yes 'y', no 'n'</property> </session-factory> </hibernate-configuration> </configuration> i apply transformation. web.release.config:
<?xml version="1.0" encoding="utf-8"?> <configuration xmlns:xdt="http://schemas.microsoft.com/xml-document-transform" xmlns:hib="urn:nhibernate-configuration-2.2"> <configsections> <section name="hibernate-configuration" type="nhibernate.cfg.configurationsectionhandler, nhibernate" requirepermission="false"/> </configsections> <hib:hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> <hib:session-factory> <hib:property xdt:transform="replace" xdt:locator="match(name)" name="connection.connection_string">{new_connection}</hib:property> </hib:session-factory> </hib:hibernate-configuration> </configuration> run in vs2012 in release, transformation not occur. string not replaced. in reason?
the transformation not happen because element names differs baseline web.config. if remove hib namespace, transformation take place.
<?xml version="1.0" encoding="utf-8"?> <configuration xmlns:xdt="http://schemas.microsoft.com/xml-document-transform"> <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> <session-factory> <property xdt:transform="replace" xdt:locator="match(name)" name="connection.connection_string">{new_connection}</property> </session-factory> </hibernate-configuration> </configuration> another thing note. if current configuration release , running application through visual studio, server point root of project. in root, have web.config, web.debug.config , web.release.config , server pick-up usual configuration file, without transformation (ie web.config).
Comments
Post a Comment