private uint GetVersionFromEsent()
{
// Create a unique name so that multiple threads can call this simultaneously.
// This can happen if there are multiple AppDomains.
string instanceName = String.Format(CultureInfo.InvariantCulture, "GettingEsentVersion{0}", Thread.CurrentThread.ManagedThreadId);
JET_INSTANCE instance = JET_INSTANCE.Nil;
RuntimeHelpers.PrepareConstrainedRegions();
try
{
this.JetCreateInstance(out instance, instanceName);
this.JetSetSystemParameter(instance, JET_SESID.Nil, JET_param.Recovery, 0, "off");
this.JetSetSystemParameter(instance, JET_SESID.Nil, JET_param.NoInformationEvent, 1, null);
this.JetSetSystemParameter(instance, JET_SESID.Nil, JET_param.MaxTemporaryTables, 0, null);
this.JetSetSystemParameter(instance, JET_SESID.Nil, JET_param.MaxCursors, 16, null);
this.JetSetSystemParameter(instance, JET_SESID.Nil, JET_param.MaxOpenTables, 16, null);
this.JetSetSystemParameter(instance, JET_SESID.Nil, JET_param.MaxVerPages, 4, null);
this.JetSetSystemParameter(instance, JET_SESID.Nil, JET_param.MaxSessions, 1, null);
this.JetInit(ref instance);
JET_SESID sesid;
this.JetBeginSession(instance, out sesid, String.Empty, String.Empty);
try
{
uint version;
this.JetGetVersion(sesid, out version);
return version;
}
finally
{
this.JetEndSession(sesid, EndSessionGrbit.None);
}
}
finally
{
if (JET_INSTANCE.Nil != instance)
{
this.JetTerm(instance);
}
}
}