I need long path support for my .net 4.5.1 WPF application.
This setting in App.config works (long paths are supported):
<runtime>
<AppContextSwitchOverrides value="Switch.System.IO.UseLegacyPathHandling=false;Switch.System.IO.BlockLongPaths=false" />
</runtime>
So I tried to set in in code, but it does not change the behaviour:
public App()
{
// returns correct type:
Type type = Type.GetType("System.AppContext");
if (type != null)
{
// returns correct switch:
MethodInfo setSwitch = type.GetMethod("SetSwitch", BindingFlags.Public | BindingFlags.Static);
setSwitch.Invoke(null, new object[] { "Switch.System.IO.UseLegacyPathHandling", false });
setSwitch.Invoke(null, new object[] { "Switch.System.IO.BlockLongPaths", false });
}
}
Is that "code behind setting" not supported in .net 4.5.1?