Here's what I needed to do in order to get the saved searches to work in C# SDK 2.x.
Edit the following Class: **splunk-sdk-csharp-pcl-2.2.6\src\Splunk.Client\Splunk\Client\AtomEntry.cs**
**Replace the following code on starting on line 401:**
for (int i = 0; i < names.Length - 1; i++)
{
propertyName = NormalizePropertyName(names[i]);
if (dictionary.TryGetValue(propertyName, out propertyValue))
{
if (!(propertyValue is ExpandoObject))
{
throw new InvalidDataException(name); // TODO: Diagnostics : conversion error
}
}
else
{
propertyValue = new ExpandoObject();
dictionary.Add(propertyName, propertyValue);
}
dictionary = (IDictionary)propertyValue;
}
propertyName = NormalizePropertyName(names[names.Length - 1]);
propertyValue = await ParsePropertyValueAsync(reader, level + 1).ConfigureAwait(false);
dictionary.Add(propertyName, propertyValue);
**Replaced the above code with this one:**
bool addDictionary = false;
for (int i = 0; i < names.Length - 1; i++)
{
addDictionary = true;
propertyName = NormalizePropertyName(names[i]);
if (dictionary.TryGetValue(propertyName, out propertyValue))
{
if (!(propertyValue is ExpandoObject))
{
// throw new InvalidDataException(name); // TODO: Diagnostics : conversion error
addDictionary = false;
}
}
else
{
propertyValue = new ExpandoObject();
dictionary.Add(propertyName, propertyValue);
}
if (addDictionary)
{
dictionary = (IDictionary)propertyValue;
}
}
try
{
propertyName = NormalizePropertyName(names[names.Length - 1]);
propertyValue = await ParsePropertyValueAsync(reader, level + 1).ConfigureAwait(false);
if (!dictionary.ContainsKey(propertyName))
{
dictionary.Add(propertyName, propertyValue);
}
}
catch (Exception er)
{ }
**Recompiled and then the saved search example worked!**
Just wondering if there's a better fix!
↧