c# - Define worker role's app.config section handler in webrole's model folder -
this first time creating custom configuration section class app.config worker role. able worker role when defined custom section class inside workerrole1 project, , app.config section so:
<configsections> <sectiongroup name="environmentinfogroup"> <section name="environmentinfo" type="workerrole1.environmentinfosection, workerrole1" allowlocation="true" allowdefinition="everywhere" /> </sectiongroup> </configsections>
however, moved environmentinfosection class mvcwebrole1.models , changed app.config to:
<configsections> <sectiongroup name="environmentinfogroup"> <section name="environmentinfo" type="mvcwebrole1.models.environmentinfosection, mvcwebrole1.models" allowlocation="true" allowdefinition="everywhere" /> </sectiongroup> </configsections>
at line of
configurationmanager.getsection("environmentinfogroup/environmentinfo") environmentinfosection;
i got exception of
innerexception {"an error occurred creating configuration section handler environmentinfogroup/environmentinfo: not load file or assembly 'mvcwebrole1.models' or 1 of dependencies. system cannot find file specified.
since worker role using other classes same folder in webrole, mean cannot share classes across webrole workerrole configuration things? or there missed?
i found doesn't directly apply answer problem. however, did having 2 same environmentinfosection defined in both worker , web role projects , 2 same config sections in app.config , web.config.
i noticed in app.config:
<configsections> <sectiongroup name="environmentinfogroup"> <section name="environmentinfo" type="workerrole1.environmentinfosection, workerrole1" allowlocation="true" allowdefinition="everywhere" /> </sectiongroup> </configsections>
is correct, in web.config (webrole)
<configsections> <sectiongroup name="environmentinfogroup"> <section name="environmentinfo" type="webrole1.models.environmentinfosection" allowlocation="true" allowdefinition="everywhere" /> </sectiongroup> </configsections>
is correct way. note difference in web.config, there no "comma" followed namespace after in type definition.
Comments
Post a Comment