System.UnauthorizedAccessException вызывается в нашем приложении Xamarin iOS при чтении общего файла из другого приложения или через общедоступную папку.
Эта ошибка новый и начался после обновления с VS2019 до VS2022 (Windows). Также было несколько обновлений macOS (сейчас Ventura 13.7). Код обмена работает нормально, но, похоже, отсутствуют настройки безопасности. Надеемся, это простая оплошность.
Ниже приведены фрагменты из приложения. Есть предложения, с чего начать поиск причины?
info.plist:
CFBundleTypeName
Public plain-text
LSItemContentTypes
public.plain-text
AppDelegate.cs:
public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
{
MyModule mm = new MyModule();
mm.AddFile(url.Path);
return true;
}
MyModule.cs:
public class MyModule
{
public void AddFile(string url)
{
...
var text = File.ReadAllText(url); >
...
}
}
Сообщение об исключении:
{System.UnauthorizedAccessException: Access to the path "/private/var/mobile/Containers/Shared/AppGroup/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/File Provider Storage/xxxxx.txt" is denied.
at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0026e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.IO/FileStream.cs:274
at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.IO.FileOptions options) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.IO/FileStream.cs:106
at System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding, System.Boolean detectEncodingFromByteOrderMarks, System.Int32 bufferSize) [0x00055] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/IO/StreamReader.cs:182
at System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding, System.Boolean detectEncodingFromByteOrderMarks) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/IO/StreamReader.cs:167
at System.IO.File.InternalReadAllText (System.String path, System.Text.Encoding encoding) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.IO.FileSystem/src/System/IO/File.cs:303
at System.IO.File.ReadAllText (System.String path) [0x00026] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/System.IO.FileSystem/src/System/IO/File.cs:282
at [App].MyModule.AddFile (System.String fullPath) [0x00002] in C:\xxxx\...\xxxx.cs:187 }
Подробнее здесь: https://stackoverflow.com/questions/791 ... denied-rea
Xamarin iOS System.UnauthorizedAccessException: доступ к пути запрещен при чтении общих файлов ⇐ C#
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Xamarin iOS System.UnauthorizedAccessException: доступ к пути запрещен при чтении общих файлов
Anonymous » » в форуме C# - 0 Ответы
- 18 Просмотры
-
Последнее сообщение Anonymous
-
-
-
SQL Server Unkending Exception. System.UnauthorizedAccessException: доступ к пути отрицается
Anonymous » » в форуме C# - 0 Ответы
- 2 Просмотры
-
Последнее сообщение Anonymous
-