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

Fail to load (with Roaming Profile?) #60

Closed
mikeminutillo opened this issue Jan 12, 2012 · 4 comments
Closed

Fail to load (with Roaming Profile?) #60

mikeminutillo opened this issue Jan 12, 2012 · 4 comments

Comments

@mikeminutillo
Copy link
Contributor

So far my experiments have shown that I cannot load MarkPad under my corporate account but I can under my regular account. I suspect this has to do with my Roaming Profile and I'm happy to explorer further. Details as recorded in the Event Log are as follows:

Application: MarkPad.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: Autofac.Core.DependencyResolutionException
Stack:
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(System.String[])
at MarkPad.SingleInstanceManager.Main(System.String[])

@ghost
Copy link

ghost commented Feb 15, 2012

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

@mikeminutillo
Copy link
Contributor Author

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.

@mikeminutillo
Copy link
Contributor Author

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.

@ghost
Copy link

ghost commented Mar 27, 2012

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

@ghost
Copy link

ghost commented Mar 27, 2012

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

@lissht
Copy link

lissht commented Feb 19, 2013

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

@shiftkey
Copy link
Member

shiftkey commented Feb 4, 2014

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

@shiftkey shiftkey closed this as completed Feb 5, 2014
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

3 participants