- Home /
Exception: INTERNAL configuration error: failed to get configuration 'system.diagnostics'
I am currently working on getting the Amazon Web Service, SimpleDB to work on iOS.
I am using a third part C# lib for AWS SimpleDB called Simple Savant. http://simol.codeplex.com/
Simple Savant works great in the editor, but I have had a few issues with getting it to run on iOS. I have been able to use the latest release's source code to build for myself as I needed to be able to get around a JIT compile issue regard .GetValue(), which I replaced with .GetGetMethod().Invoke(), that seemed to work well. Unfortunately I have hit a bit of a roadblock, as I am unable to get past my latest exception.
Exception: INTERNAL configuration error: failed to get configuration 'system.diagnostics' at System.Diagnostics.DiagnosticsConfiguration.get_Settings () [0x00000] in <filename unknown>:0 at System.Diagnostics.TraceImpl.InitOnce () [0x00000] in <filename unknown>:0 at System.Diagnostics.TraceImpl.get_Listeners () [0x00000] in <filename unknown>:0 at System.Diagnostics.TraceImpl.get_ListenersSyncRoot () [0x00000] in <filename unknown>:0 at System.Diagnostics.TraceImpl.Write (System.String message) [0x00000] in <filename unknown>:0 at System.Diagnostics.Trace.Write (System.String message) [0x00000] in <filename unknown>:0 at Amazon.SimpleDB.AmazonSimpleDBClient.Invoke[CreateDomainResponse] (IDictionary`2 parameters) [0x00000] in <filename unknown>:0 at Amazon.SimpleDB.AmazonSimpleDBClient.CreateDomain (Amazon.SimpleDB.Model.CreateDomainRequest request) [0x00000] in <filename unknown>:0 at Coditate.Savant.Core.DecoratingSimpleDB.CreateDomain (Amazon.SimpleDB.Model.CreateDomainRequest request) [0x00000] in <filename unknown>:0 at Coditate.Savant.Core.DomainCreatingSavant.EnsureDomain (System.String domainName) [0x00000] in <filename unknown>:0 at Coditate.Savant.Core.DomainCreatingSavant.PutAttributes (Coditate.Savant.ItemMapping mapping, Coditate.Savant.PropertyValues[] values) [0x00000] in <filename unknown>:0 at Coditate.Savant.Core.DecoratingSavant.PutAttributes (Coditate.Savant.ItemMapping mapping, Coditate.Savant.PropertyValues[] values) [0x00000] in <filename unknown>:0 at Coditate.Savant.Core.ConstrainingSavant.PutAttributes (Coditate.Savant.ItemMapping mapping, Coditate.Savant.PropertyValues[] values) [0x00000] in <filename unknown>:0 at Coditate.Savant.SimpleSavant.Put (System.Object[] items) [0x00000] in <filename unknown>:0 at DatabaseCore.WriteToDB () [0x00000] in <filename unknown>:0 at LoginScreen.OnLogin () [0x00000] in <filename unknown>:0
(Filename: Line: -1)
I am using Unity 3.3, with an iPad 2 on OS X Snow Leopard.
My Api Compatibility Level is set to ".NET 2.0"
My stripping level is set to "Disabled"
I am able to build out to the device, but when I trigger my DatabaseCore.WriteToDB method, I get an exception, and I am unsure how to proceed. If anyone has any thoughts, please let me know!
- E
Answer by Incarnadine · Feb 08, 2013 at 06:32 PM
Besides not providing a good way to get an app.config file where it belongs in the deployment, Unity has also done something funky with the config system where it's not even recognizing the default configuration handlers registered in machine.config. I was able to work around this as follows.
Add System.Configuration.dll to your Assets folder. This is already included in a normal player build from what I can tell, but for some reason doesn't get added as a project reference.
Add an app.config to Assets/StreamingAssets
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<configSections>
<section name="system.diagnostics" type="System.Diagnostics.DiagnosticsConfigurationHandler, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<system.diagnostics>
<trace autoflush="true" />
</system.diagnostics>
</configuration>
Register it on startup with some reflection hackery.
void InitializeAppConfig()
{
var configFile = Application.streamingAssetsPath + "/app.config";
Debug.Log("App Config Path: " + configFile);
var configFileMap = new ExeConfigurationFileMap() {
ExeConfigFilename = configFile
};
var config = ConfigurationManager.OpenMappedExeConfiguration(
configFileMap, ConfigurationUserLevel.None);
var configSystemField = typeof(ConfigurationManager).GetField("configSystem",
System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
var configSystem = configSystemField.GetValue(null);
Debug.Log("ConfigSystem type = " + configSystem.GetType().ToString());
var cfgField = configSystem.GetType().GetField("cfg",
System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
cfgField.SetValue(configSystem, config);
}
This should work with all players with access to the file system. The web player won't work with this approach and probably not the Android one either since the app is in a JAR. With more time staring at the code to Mono it might be possible to hack a Configuration instance that doesn't rely solely on the file system to read the config for more platforms.