Ten wpis na blogu pokazuje, jak ustawić tę zasadę w środowisku wykonawczym (w porównaniu z "projektem-czasem" - edytując web.config) http://reedcopsey.com/2011/09/15/setting-uselegacyv2runtimeactivationpolicy-at-runtime/, ale nie wypróbowałem go sam w ASP.NET 5. Pracował jednak nad wcześniejszymi wersjami.
Zasadniczo utworzyć ta statyczna klasy pomocnika
public static class RuntimePolicyHelper
{
public static bool LegacyV2RuntimeEnabledSuccessfully { get; private set; }
static RuntimePolicyHelper()
{
ICLRRuntimeInfo clrRuntimeInfo =
(ICLRRuntimeInfo)RuntimeEnvironment.GetRuntimeInterfaceAsObject(
Guid.Empty,
typeof(ICLRRuntimeInfo).GUID);
try
{
clrRuntimeInfo.BindAsLegacyV2Runtime();
LegacyV2RuntimeEnabledSuccessfully = true;
}
catch (COMException)
{
// This occurs with an HRESULT meaning
// "A different runtime was already bound to the legacy CLR version 2 activation policy."
LegacyV2RuntimeEnabledSuccessfully = false;
}
}
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("BD39D1D2-BA2F-486A-89B0-B4B0CB466891")]
private interface ICLRRuntimeInfo
{
void xGetVersionString();
void xGetRuntimeDirectory();
void xIsLoaded();
void xIsLoadable();
void xLoadErrorString();
void xLoadLibrary();
void xGetProcAddress();
void xGetInterface();
void xSetDefaultStartupFlags();
void xGetDefaultStartupFlags();
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
void BindAsLegacyV2Runtime();
}
}
Zastosowanie:
// before calling the code from your legacy assembly -
if (RuntimePolicyHelper.LegacyV2RuntimeEnabledSuccessfully)
{
// your Legacy code
}
Hi powitanie tak, proszę podać podsumowanie pytanie (nie wystaje listę technologii) w tytule. Zazwyczaj technologie powinny być wymienione za pomocą znaczników – Liam