Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IsolatedStorageFile Throws System.UriFormatException #110319

Closed
MissyGH opened this issue Dec 2, 2024 · 6 comments
Closed

IsolatedStorageFile Throws System.UriFormatException #110319

MissyGH opened this issue Dec 2, 2024 · 6 comments

Comments

@MissyGH
Copy link

MissyGH commented Dec 2, 2024

Description

Using Net 9 when I call this and the program is on a network location: IsolatedStorageFile.GetUserStoreForAssembly() the system throws an error.

It works in Net 8 and it works when I call it from a local drive.

Reproduction Steps

Below is the entirety of the program.

using System.IO.IsolatedStorage;

namespace Net9_IsolatedStorage
{
    internal static class Program
    { 
        [STAThread]
        static void Main()
        { 
             IsolatedStorageFile isolatedStorageFile = IsolatedStorageFile.GetUserStoreForAssembly();             
        }
    }
}

Expected behavior

No error is expected

Actual behavior

Exception in this line IsolatedStorageFile isolatedStorageFile = IsolatedStorageFile.GetUserStoreForAssembly();:

Exception Info: System.UriFormatException: Invalid URI: The hostname could not be parsed.
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
at System.Uri..ctor(String uriString)
at System.IO.IsolatedStorage.Helper.GetDefaultIdentityAndHash(Object& identity, String& hash, Char separator)
at System.IO.IsolatedStorage.IsolatedStorage.InitStore(IsolatedStorageScope scope, Type domainEvidenceType, Type assemblyEvidenceType)
at System.IO.IsolatedStorage.IsolatedStorageFile..ctor(IsolatedStorageScope scope)
at System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForAssembly()
at Net9_NoTelerikControls.Program.Main() in D:\RMSCSharp\TestDesigner\241129\Program.cs:line 15

Regression?

It works when I target Net8

Known Workarounds

None with Net 9

Configuration

Net 9
Windows 10
x64 or x86

Other information

This seems to be specific to trying to use Isolated Storage on the network. It works when I run the exe on a local drive. When I copy it to the network and run it from a network location, I get the exception.

Example:
241202.zip

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Dec 2, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-io
See info in area-owners.md if you want to be subscribed.

@jeffhandley
Copy link
Member

Assigned to @jozkee for triage.

@jozkee
Copy link
Member

jozkee commented Jan 17, 2025

Something changed in System.Reflection that caused this bug.
This program gives the following results when its run from a mapped network drive (Z: is \\localhost).

string location = Assembly.GetEntryAssembly()!.Location;
Console.WriteLine(location);
var uri  = new Uri(location);
Z:\>"./net8.0/ConsoleApp27.exe"
Z:\net8.0\ConsoleApp27.dll

Z:\>"./net9.0/ConsoleApp27.exe"
\\?\UNC\localhost\Public\net9.0\ConsoleApp27.dll
Unhandled exception. System.UriFormatException: Invalid URI: The hostname could not be parsed.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
   at System.Uri..ctor(String uriString)
   at Net9_IsolatedStorage.Program.Main() in C:\Users\dacantu\source\repos\ConsoleApp27\Program.cs:line 14

@jozkee jozkee removed their assignment Jan 17, 2025
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-reflection
See info in area-owners.md if you want to be subscribed.

@jozkee
Copy link
Member

jozkee commented Jan 18, 2025

Probably has the same root cause as #109846 (comment).

@steveharter
Copy link
Member

Closing as duplicate; please verify - the fix should be in via #110033.

@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants