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

OLW won't open local drafts or published posts, throws an UnauthorizedAccessException #26

Closed
hmemcpy opened this issue Dec 9, 2015 · 11 comments
Assignees
Milestone

Comments

@hmemcpy
Copy link
Contributor

hmemcpy commented Dec 9, 2015

I get this exception trying to open (Windows) Live Writer drafts, or already published posts. The exception is:

System.UnauthorizedAccessException
"Access to the path 'C:\Users\hmemcpy\AppData\Local\Temp\OpenLiveWriter1894151082\supfiles2DD0C2\SpellingContext' is denied."

I traced the origin to these lines: https://github.com/OpenLiveWriter/OpenLiveWriter/blob/master/src/managed/OpenLiveWriter.PostEditor/BlogPostSupportingFileStorage.cs#L129-L130
It seems that CONTEXT_DICTIONARY_FILE is currently set to an empty string (per @shanselman's post, spell checking is currently removed), which creates an invalid path and causes FileStream to fail.

I commented out this method for now, but I'm not sure that's a good PR to send.

@RobDolinMS RobDolinMS added this to the v0.6 milestone Dec 9, 2015
@zosoro
Copy link

zosoro commented Dec 9, 2015

Same here

miercuri, 9 decembrie 2015 20:58:28

Version: 0.5.0.0

OS Version: Microsoft Windows NT 6.1.7601 Service Pack 1
Runtime version: 4.0.30319.34209
Shutdown started: False
Program: "C:\Users\vali\AppData\Local\OpenLiveWriter\app-0.5.0.0\OpenLiveWriter.exe"

Memory Load: 33%
Total Physical: 16279 MB
Available Physical: 10899 MB
Total Page File: 16277 MB
Available Page File: 9798 MB
Total Virtual: 2047 MB
Available Virtual: 1733 MB
Available Extented Virtual: 0 MB

Unexpected Error Occurred
An unexpected error has occurred within the application.

OpenLiveWriter.PostEditor.PostEditorStorageException: Error Accessing Local Post - Unexpected error occurred while accessing local post (UnauthorizedAccessException)

Access to the path 'C:\Users\vali\AppData\Local\Temp\OpenLiveWriter-1499964508\supfiles5CD581C\SpellingContext' is denied.
at OpenLiveWriter.PostEditor.PostEditorFile.Load(Boolean addToRecentDocs)
at OpenLiveWriter.PostEditor.BlogPostEditingManager.OpenLocalPost(PostInfo postInfo)
at OpenLiveWriter.PostEditor.PostEditorMainControl.OpenLiveWriter.PostEditor.IBlogPostEditingSite.OpenLocalPost(PostInfo postInfo)
at OpenLiveWriter.PostEditor.Commands.DraftPostItemsGalleryCommand.DraftPostItemsGalleryCommand_Execute(Object sender, EventArgs e)
at OpenLiveWriter.ApplicationFramework.Command.RaiseEvent(Object eventKey, EventArgs e)
at OpenLiveWriter.ApplicationFramework.Command.OnExecute(EventArgs e)

@bsimser
Copy link

bsimser commented Dec 10, 2015

I get this too. Have a post I wrote with WLW and realized OLW was seeing it so tried to open it. Got the same error. Post opens fine in WLW. Debugging this now and might have a PR to fix it later tonight.

@bsimser
Copy link

bsimser commented Dec 10, 2015

Hey @willduff just wondering on this. I have a quick fix but wanted to pass this by before submitting it.

The root cause of the problem as @hmemcpy mentioned is line 130 in BlogPostSupportingFileStorage.cs. This tries to create a file in the dictionary path to copy the spelling context dictionary to the file storage. Not sure when opening an old post why it needs another dictionary but okay, let's go roll with that.

Tracing it through it starts in PostEditorFile.cs at line 383 where it calls a method named ReadSpellingContextDictionary. That method (line 1008) doesn't just read the dictionary but also writes it to the supporting file storage. Its when it hits line 1017 it calls the WriteSpellingContextDictionary method on the filestorage. Without a CONTEXT_DICTIONARY_FILE name it's trying to write to a filename named as an empty string. This is where the exception happens.

So easy solution I think to allow you to open WLW posts is to wrap WriteSpellingContextDictionary in a try/catch, it'll fail on the write, and move on. The effect (I think) is that the user won't have a dictionary to read from for that posts. I tried this out and it behaves fine but I'm not sure of the longer implications here, although this method is only used when loading posts from local storage.

Thoughts on doing the fix this way and sending in a PR with it? Or...

I think there's a bigger issue when I look at the ReadSpellingContextDictionary and WriteSpellingContextDictionary methods in PostEditorFile.cs (lines 1008 - 1030) and the same named methods in BlogPostSupportingFileStorage.cs (lines 127 - 143). They both do similar things but I think the naming is off (ReadSpellingContextDictionary in PostEditorFile.cs should maybe be called TransferSpellingContextDictionary as that's what it does and the 4 methods all do almost the same things but in slighty different ways.

An alternate fix (which I tried and works as well) is to remove both ReadSpellingContextDictionary and WriteSpellingContextDictionary from PostEditorFile.cs and use the methods in BlogPostSupportingFileStorage.cs instead.

Thanks

@bsimser
Copy link

bsimser commented Dec 10, 2015

One more update. Reading this code again now I realized what's going on. When loading a post it's reading the dictionary in the post and writes it to the (local) storage. When it saves the post it reads the dictionary from the storage and writes it back to the post again. I supposed this is so I can have a custom dictionary attached to each post? Without a spell checker right now maybe both of these methods just need to be either commented out/removed until a spell checker solution comes along? At least that would allow people to open WLW drafts and posts.

@jakobehn
Copy link

Seeing the same issue. I think commenting out the code related to spell checker dictionaries makes sense now as it is not supported and once it is, this code most likely will have to be changed anyway

@bsimser
Copy link

bsimser commented Dec 11, 2015

Going to remove the code until a new spell checker comes along. There's a different registry error trying to save WLW posts but I'll file a different bug with that once this is in place.

@quadrathon
Copy link

Got this Exception this morning, I haven't looked closely but looks very similar to one reported above

Thursday, December 17, 2015 10:01:16 AM

Version: 0.5.1.2

OS Version: Microsoft Windows NT 6.1.7601 Service Pack 1
Runtime version: 4.0.30319.18444
Shutdown started: False
Program: "C:\Users\sbarrington\AppData\Local\OpenLiveWriter\app-0.5.1.2\OpenLiveWriter.exe"

Memory Load: 37%
Total Physical: 16281 MB
Available Physical: 10140 MB
Total Page File: 32560 MB
Available Page File: 25583 MB
Total Virtual: 2047 MB
Available Virtual: 1603 MB
Available Extented Virtual: 0 MB

Unexpected Error Occurred
An unexpected error has occurred within the application.

OpenLiveWriter.PostEditor.PostEditorStorageException: Error Accessing Local Post - Unexpected error occurred while accessing local post (UnauthorizedAccessException)

Access to the path 'C:\Users\sbarrington\AppData\Local\Temp\OpenLiveWriter-466258407\supfiles3170AB9\SpellingContext' is denied.
at OpenLiveWriter.PostEditor.PostEditorFile.Load(Boolean addToRecentDocs)
at OpenLiveWriter.PostEditor.BlogPostEditingManager.OpenLocalPost(PostInfo postInfo)
at OpenLiveWriter.PostEditor.PostEditorMainControl.OpenLiveWriter.PostEditor.IBlogPostEditingSite.OpenLocalPost(PostInfo postInfo)
at OpenLiveWriter.PostEditor.Commands.RecentItemsCommand.RecentItemsCommand_ExecuteWithArgs(Object sender, ExecuteEventHandlerArgs args)
at OpenLiveWriter.ApplicationFramework.Command.RaiseEvent(Object eventKey, ExecuteEventHandlerArgs e)
at OpenLiveWriter.ApplicationFramework.Command.OnExecute(ExecuteEventHandlerArgs args)

@willduff
Copy link
Member

This is our top priority bug due to the number of hits we are seeing on this. I haven't had a chance to look through the discussion but will circle back as soon as I can!

@willduff
Copy link
Member

I opened pull request #211 to fix this.

The root cause here is that we accidentally made a breaking change when we removed the spell checking logic. We changed the CONTEXT_DICTIONARY_FILE constant from "context.tlx" to string.Empty. That means in the WriteSpellingContextDictionary() and ReadSpellingContextDictionary() methods, we were resolving a dictionary path as Path.Combine(SpellingContextDirectory, string.Empty); and then tried to create a FileStream on a directory. The fix here is simple, just change the dictionary filename back to "context.tlx".

@hmemcpy
Copy link
Contributor Author

hmemcpy commented Dec 22, 2015

Awesome! Thanks for the fix! :shipit:

ScottIsAFool added a commit that referenced this issue Dec 22, 2015
Issue #26 - OLW won't open local drafts or published posts, throws an UnauthorizedAccessException
@willduff willduff closed this as completed Feb 7, 2016
@bremhillbob
Copy link

I've just come across the same error using version 0.6.2. I'm a very 'non technical' guy just looking for an easy blogging solution and WLR or OLW are perfect for me (I just can't get them to work). Anyone any suggestions? (for a non tech)

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

8 participants