I have 2 COM+ applications built in C#. They need access to a configuration, so in order to get them that (since they are in a server context) I set the Application Root Directory in the COM+ application to be a directory that contains an application.manifest and application.config file. The first component I built this way works. The second component, which I cannot find a single meaningful difference in the way I wrote it, does not.
If you try to access the configuration using ConfigurationManager.GetSection("unity")
from a static context, it will return null. Calling the same thing from a non-static context produces the expected results (the section is returned). Since the first component works correctly calling that from a static context, what am I doing wrong?
Works in DLL 1, but not in DLL 2:
private static IUnityContainer m_unityContainer = new UnityContainer().LoadConfiguration()
Works in DLL 2:
private IUnityContainer m_unityContainer = new UnityContainer().LoadConfiguration()
or
private IUnityContainer m_unityContainer;
public void Process()
{
m_unityContainer = new UnityContainer().LoadConfiguration();
}
I'm not sure, but I think this had something to do with the differences in x64 and x86. I solved it by changing the code to
private static readonly Lazy<IUnityContainer> m_unityContainer = new Lazy<IUnityContainer>(() => new UnityContainer().LoadConfiguration());