
Originally Posted by
Steve Bohlen
Can you provide your Spring.NET config file(s) as well as your app.config/web.config files?
Also, if this isn't a web app, can you post the code you're using to new-up the ###ApplicationContext you are using?
Thanks,
-Steve B.
It is a desktop application. The problem is strangly only sporadic. It went away yesterday. I don't know what I have done that broke/fixed it. Below are the c# code and app.config file. The problem should not be in the configuration file. I did several things to intentionally break the configuration
1. make the app.config invalid
2. make the file path in <resource uri="filex://%SOMARIS_CONFIG%/CT/System/SpringConfig_SRI.xml" /> invalid
and always got different exception than the one I mentioned above.
When everything is working fine.
_configurationLocations is a one element string array
with _configurationLocations[0] = “filex:%SOMARIS_CONFIG%/CT/System/Spring/Spring_config.xml”
In the excpetion case, the array is always empty
Spring.NET code that throws the exception
Code:
public XmlApplicationContext(XmlApplicationContextArgs args)
: base(args.Name, args.CaseSensitive, args.ParentContext)
{
_configurationLocations = args.ConfigurationLocations;
_configurationResources = args.ConfigurationResources;
if (args.Refresh)
{
bool hasLocations = args.ConfigurationLocations.Length > 0;
bool hasResources = args.ConfigurationResources.Length > 0;
if (!hasLocations && !hasResources)
throw new ArgumentException("You must provide either or both Configuration Locations and/or Configuration Resources!");
My code for creating the spring contaxt
Code:
static void Main(string[] args)
{
// register exception handler
try
{
// set the exception handler
SetExceptionHandler();
}
catch (Exception e)
{
// Handle the exception using the global exception handler
ExceptionHandler exceptionHandler = new ExceptionHandler();
exceptionHandler.HandleException("CT.System caught exception during exception handler registration!", e);
}
IApplicationContext context = ContextRegistry.GetContext();
ServiceHost host = (ServiceHost)context.GetObject("ServiceHost");
host.Open();
Console.WriteLine("Hit enter to stop the application.");
Console.ReadLine();
host.Close();
}
My configuration file
Code:
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" />
<section name="resourceHandlers" type="Spring.Context.Support.ResourceHandlersSectionHandler, Spring.Core"/>
</sectionGroup>
</configSections>
<spring>
<resourceHandlers>
<handler protocol="filex" type="CT.Common.SpringExpansion.Contract.ExpandableFileSystemResource, CT.Common.SpringExpansion.Contract"/>
</resourceHandlers>
<context>
<resource uri="filex://%SOMARIS_CONFIG%/CT/System/SpringConfig_SRI.xml" />
</context>
</spring>
<system.web>
<compilation debug="true"/>
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="CT.Common.Aop.Server.WcfServer">
<clear />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"
listenUriMode="Explicit" />
<endpoint address="net.pipe://localhost/Wcf/Scanner" binding="netNamedPipeBinding"
bindingConfiguration="" contract="CT.Common.Aop.Contract.IWcfService" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/CT.System.WcfService/WcfServiceCore/" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<netNamedPipeBinding>
<!--Remark: To set the buffer size might not be a good idea, as it is of static content (should better be set dynamically).
Also we might get trouble in the future, because name pipe declarations do only work with in the scope of one machine.-->
<binding
maxBufferPoolSize="965536"
maxBufferSize="965536"
maxReceivedMessageSize="965536">
<readerQuotas maxStringContentLength="965536" />
<security mode="Transport">
<transport protectionLevel="EncryptAndSign" />
</security>
</binding>
</netNamedPipeBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="True"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<!--Runtime Execution Settings-->
<runtime>
<legacyUnhandledExceptionPolicy enabled="1"/>
<generatePublisherEvidence enabled="false"/>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath=".\DoDll;.\dll;.\extern;.\DoTestDll;.\testdll"/>
</assemblyBinding>
<disableCommitThreadStack enabled="1"/>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>