Giter VIP home page Giter VIP logo

Comments (7)

 avatar commented on July 30, 2024

Have you been able to replicate this? I know there was discussion in Jabbr, not sure whether there was progress made.

from downmarkerwpf.

mikeminutillo avatar mikeminutillo commented on July 30, 2024

I am am able to perfectly replicate it by attempting on my account with a roaming profile using the following (in LinqPad):

    IsolatedStorageFile.GetStore(IsolatedStorageScope.Assembly | IsolatedStorageScope.User | IsolatedStorageScope.Roaming, null, null);

I get this:

System.IO.IsolatedStorage.IsolatedStorageException: Initialization failed.
   at System.IO.IsolatedStorage.IsolatedStorageFile.Init(IsolatedStorageScope scope)
   at System.IO.IsolatedStorage.IsolatedStorageFile.GetStore(IsolatedStorageScope scope, Type domainEvidenceType, Type assemblyEvidenceType)
   at UserQuery.RunUserAuthoredQuery() in c:\Users\Minutilm\AppData\Local\Temp\ge52ot3a.0.cs:line 33

It works fine on my regular profile but not my roaming profile. Having a quick look with reflector this probably happens when the System.IO.LongPathDirectory.CreateDirectory(..) [internal class and method] fails. Sadly the IsolatedStorageFile class swallows any exception and simply throws its own "Initialization failed" exception so the details of why are lost. I'll attempt some reflector-fu and see if I can reproduce the underlying issue.

from downmarkerwpf.

mikeminutillo avatar mikeminutillo commented on July 30, 2024

OK I have confirmed that this is the issue and I believe that it is unique to my environment. Here is the code that GetStore(..) is running (more or less):

var scope = IsolatedStorageScope.Assembly | IsolatedStorageScope.User | IsolatedStorageScope.Roaming;

var instance = (IsolatedStorageFile)Activator.CreateInstance(typeof(IsolatedStorageFile), true);
typeof(IsolatedStorage).GetMethod("InitStore", BindingFlags.NonPublic | BindingFlags.Instance, null, new[] { typeof(IsolatedStorageScope), typeof(Type), typeof(Type) }, null).Invoke(instance, new object[] { scope, null, null });

var RootDir = typeof(IsolatedStorageFile).GetMethod("GetRootDir", BindingFlags.Static | BindingFlags.NonPublic, null, new[] { typeof(IsolatedStorageScope) }, null).Invoke(null, new object[] { scope }).Dump("Root Dir");
var AssemName = typeof(IsolatedStorage).GetProperty("AssemName", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(instance, null).Dump("Assem Name");
var SeparatorExternal = typeof(IsolatedStorageFile).GetProperty("SeparatorExternal", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(instance, null).Dump("Separator External");

var path = String.Join("", new[] { RootDir, AssemName, SeparatorExternal }).Dump("Path");

try {
    Type.GetType("System.IO.LongPathDirectory").GetMethod("CreateDirectory", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, new object[] { path });
}
catch(TargetInvocationException tex)
{
    tex.InnerException.ToString().Dump();
}

This shows that the path it is trying to create exists under a UNC path \\myserver\userAccountm$\profile\Application Data\IsolatedStorage\ and it throws the following:

System.IO.IOException: The filename, directory name, or volume label syntax is incorrect.

   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.LongPathDirectory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj)
   at System.IO.LongPathDirectory.CreateDirectory(String path)

This is not the first app that has run into this sort of issue with my roaming profile set up. We can potentially fix this by having a boolean setting to indicate whether Roaming profile is to be used or not because turning it off makes it work from my local drive. If that sounds OK I'll add it and send a pull request.

from downmarkerwpf.

 avatar commented on July 30, 2024

Sorry, I failed to see the question at the end of this - yes, falling back to local directory for settings works for me. I think we've now changed to a XML based (rather than binary based) storage mechanism too. ie, settings provider code is different

from downmarkerwpf.

 avatar commented on July 30, 2024

Also related (if we switch to a flag to toggle), #70

from downmarkerwpf.

lissht avatar lissht commented on July 30, 2024

It raise "System.IO.IOException: The filename, directory name, or volume label syntax is incorrect." because function "InternalCreateDirectory" before creating folder through Win32 function, add to path "\myserver\userAccountm$\profile\Application Data\IsolatedStorage" prefix "?" which main that this path have type "long UNC", (IsolatedStorage in .NET 4 work with "long UNC" and .NET 3.5 with simple UNC). Long UNC path in this case must be "?\UNC\myserver\userAccountm$\profile\Application Data\IsolatedStorage" but in is "?\myserver\userAccountm$\profile\Application Data\IsolatedStorage" that is way Win32 function return error 123 which mean "The filename, directory name, or volume label syntax is incorrect." It looks like guys in Microsoft forget test it with network paths.

Also I described this problem and workaround in social.msdn: http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/74712ff7-3611-40d0-a983-945b0307ffe8

from downmarkerwpf.

shiftkey avatar shiftkey commented on July 30, 2024

Closing this as we're using SettingsProvider.net - see JakeGinnivan/SettingsProvider.net#5 for the current state of affairs

from downmarkerwpf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.