问题
I got a external .net assembly including app.config which I need to call from a Biztalk Orchestration.
I've put some logging into the .net assembly and can see that it doesn't read or can't find the app.config file as ConfigurationManager.AppSettings.Count is 0
I installed the .net assembly to the GAC using the gacutil /i path.to.dll and i'm not sure what happens to the app.config.
Any ideas on how I make sure the app.config is being read when I call it from a Biztalk Orchestration ?
Thanks.
回答1:
BizTalk uses it's own configuration file called btsntsvc.exe.config which is in the BizTalk program files directory. You can add your configuration sections into this file and then bounce the biztalk host instances to pick up the changes.
HOWEVER, this is not good practice. It's OK to do this when you have only a single biztalk app server but if you need to scale out suddenly you have multiple config files to maintain.
The recommended approach is to use SSO to store app-specific config data, since it's BizTalk's config storage solution and therefore always available. I always use this method and have never had a any problems (although there is some overhead associated with development and management).
Details of how to go about this are here in Richard Seroter's blog.
I actually use a modified version here.
I also use the MSBuild task here to automate the deployment of new config.
Edit: posted code for wrapping the SSOCLient and calling the configuration values here
回答2:
You can also use custom solution. Create a function in your external project which will load config file as a XML document and you can fetch value from config file.
XmlDocument doc = new XmlDocument();
doc.Load(Config Path);
string value = doc.SelectSingleNode("/configuration/appSettings/add
[@key='key']/@value").Value;
来源:https://stackoverflow.com/questions/10107460/call-net-assembly-from-biztalk-orchestration-where-to-put-config