app-config

SideBySide Error with Binding Redirect in .net Windows Service

十年热恋 提交于 2019-12-04 04:46:24
问题 I have a .net windows service which needs to load two different versions of an assembly. It runs on a server 2012 R2 box. I am using a binding redirect in separate .config file which is loaded into the main app.config using this before the closing </configuration> node (see MSDN doc): <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <linkedConfiguration href="file://E:\my-service\runtime.config" /> </assemblyBinding> My runtime.config contains the actual binding redirect:

How to change configs in Spring.Net

谁都会走 提交于 2019-12-04 04:34:01
问题 An advantage of an IoC container is that you can swap in a mock service at the bottom of your object graph. However this seems much harder to do in Spring.Net than in other IoC Containers. Here's some code that does it in Unity and has Spring.Net code; namespace IocSpringDemo { using Microsoft.Practices.Unity; using NUnit.Framework; using Spring.Context; using Spring.Context.Support; public interface ISomeService { string DoSomething(); } public class ServiceImplementationA : ISomeService {

Using an external .config file in configSource produces error

喜欢而已 提交于 2019-12-04 04:18:14
I was playing around with how to use the Configuration Manager to read/write custom sections in the App.config file for a WPF application in C#. I read this excellent article on .NET 2.0 Configuration Demystified and it helped me a lot in using the config files. Here is the initial App.config file which I wrote and it works fine. App.config <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="example" type="CustomConfig.ExampleSection, CustomConfig" /> </configSections> <example version="A sample string value." /> <appSettings> <add key="version_string" value

How to set up a WCF client using wsDualHttpBinding in code?

谁说我不能喝 提交于 2019-12-04 03:55:11
I have a need to connect to a WCF service I wrote without having to deploy an app.config for the client application I'm writing. However, I've been having a very difficult time trying to figure out how to set up things from the client side in code. This is as far as I've gotten... does anyone have any ideas what I need to do to get this to work? I'd really appreciate it. This is the code I've got so far: String baseAddress = "http://localhost/CommService"; WSDualHttpBinding binding = new WSDualHttpBinding(); binding.Name = "WSDualHttpBinding_ICommService"; binding.ClientBaseAddress = new Uri

Multiple App.Config files

主宰稳场 提交于 2019-12-04 03:46:05
I want to separate my app.config file. For example I want to move ServiceModel part to another config file in the same project. How can I do that? Thanks. Marc Gravell You should be able to have an empty element with the configSource attribute set to the second file (relative to the first). See here for how to enable it for custom sections . Wilson I found the way. I changed the tag like this. <system.serviceModel> <behaviors configSource="Behaviors.config"> </behaviors> <services configSource="Services.config"> </services> <bindings configSource="Bindings.config"> </bindings> <extensions

App.Config errors with “Configuration system failed to initialize”

不问归期 提交于 2019-12-04 02:54:28
I have a console application written in C# under .net 4.0 It has a bunch of variables which I want to move into App.Config (so it will be all in one place). Added this part of code to App.Config (between configuration tags): <configuration> <appSettings> <add key="RemoteDirectory" value="Some Text Here"/> </appSettings> </configuration> In my program trying to test it with this code Console.WriteLine(ConfigurationManager.AppSettings["RemoteDirectory"]); but I keep getting "Configuration system failed to initialize" error. Try looking the Inner Exception for more detailed information. It helped

How to specify path in .config file relative to the file?

喜欢而已 提交于 2019-12-04 02:47:06
An app I use interprets a .NET .config file. I added a line specifying the path to a certificate it needs <add key="Certificate" value="..\certificate.abc"/> However, I found the app only works when run from the exact folder its .exe and .config reside. If run from another folder, it fails, because it looks for the certificate at ../ expanded relative to the working directory . What should I write in the config file, to make sure the path is ..\certificate.abc expanded relative to the config file rather the working directory? I can't change the app (it's not mine), I can only change the config

Exception when specifying defaultProxy in app.config when running NET4.0 application from network share

妖精的绣舞 提交于 2019-12-04 02:19:59
We're seeing a very strange issue when running the following application from a network share under NET4.0. When specifying a defaultProxy section in app.config a System.Net.WebException is thrown. There is no problem when running from a local drive. According to documentation applications will run as full-trust assemblies from a network share so we're assuming this should work just fine. Any ideas how we can work around this problem? Has anyone else experienced this issue or does anyone know why this might be happening? Sample program using System; using System.Net; namespace ProxyTest {

App.config settings, environment variable as partial path

别来无恙 提交于 2019-12-04 02:15:27
问题 I'm new to tinkering with app.config and xml, and am currently doing some refactoring in some code I haven't written. Currently we have a snippet which looks like this: <setting name="FirstSetting" serializeAs="String"> <value>Data Source=C:\Documents and Settings\All Users\ApplicationData\Company ...;Persist Security Info=False</value> What I'd like to do is have it instead point to something like ${PROGRAMDATA}\Company\... How can I achieve this, keeping in mind that PROGRAMDATA will not

ConfigurationElementCollection with a number of ConfigurationElements of different type

邮差的信 提交于 2019-12-04 02:09:51
Is it possible to have a CollectionElementCollection with a number of different by type CollectionElements, e.g.: <collection> <add type="MyType1, MyLib" Type1SpecificProp="1" /> <add type="MyType2, MyLib" Type2SpecificProp="2" /> </collection I have all classes required for such solution: class MyCollection : ConfigurationElementCollection { } class MyElement : ConfigurationElement { } class MyType1 : MyElement { } class MyType2 : MyElement { } ... etc but when I start my application I'm getting next predictable error: Unrecognized attribute 'Type1SpecificProp'. because Type1SpecificProp is