WPF : Access to the path ‘C:\Users\Michael\Documents\My Music’ is denied.

Recently I came across a strange issue. It would seem the WPF XAML designer for some reason wants to traverse through My Music folder.

While I am flattered the XAML Designer might be interested in “My Music”, I’m not amused that the designer actually crashes and shows this error:

Access to path denied

 

So what to make of this one? One minute I’m working normally in WPF, and the next this thing pops up and prevents me from meeting my deadline.

Google should know right? Wrong! Nothing much there besides a few other people who have come across this, and are frustrated as hell, left wondering if WPF and XAML is more of a prototype than an actual development tool.

So I decided to ask the question on Stackoverflow except the fine people over there didn’t appreciate my question. Neither did they think I deserved to ask the question:

 

Stack

 

 

So around this point in time, I have no idea what the problem is and the internet seems less than helpful. Now I know sooner or later, maybe even right now there is some other poor jerk having the same problem – who doesn’t have the luxury of Microsoft Gold Support.

That is why I am writing this, I’m going to try and investigate this problem and document my investigation process.

Step 1

The first thing I wanted to do is find out if it is a problem with just 1 XAML file or ALL XAML files in my project.

This is easy enough to do, I tried opening a few XAML files, all of them worked 5 minutes ago, none of them work now. Clearly this means:

Conclusion(s) :  Not the XAML markup causing the problem. 

Step 2

It is a system wide problem, or just a solution / project problem.

I created a new Grid Application. Lo and Behold the XAML editor worked just fine.

Conclusion(s) :  It’s something in the solution or project causing this.

Step 3

Permissions of the folder the project is in?

Added: ALL APPLICATION PACKAGES user to the folder my project is in : C:\Projects\XYZ…

Result:  Nothing

Added : My own account to the folder (even though I am administrator) and assigned full control

Result: Nothing

Conclusion(s) :   Don’t think its permissions can’t really be sure though (maybe I missed something?)

Step 4

Create a copy of the solution and project, and try and tear it apart to see what is wrong.

So I create a copy of C:\Projects\XYZ -> C:\Projects\ABC….

Now where to start tearing this thing down?

Well for starters the new copied solution and project throw the same error.

4.1 Delete images in \Images dir.  (I know its a bit lame, but last thing I did was add an image, so let’s see)

Result:  Nothing

4.2 Delete fonts – Yes I had some embedded fonts, Maybe that is the problem?

Result: Nothing

4.3 Mmm maybe it’s time to start looking at references.

4.3.1 Removed:  WPFAnimatedgif.dll

Result:  Worked…..

AHA…….

So its a reference that does this…. But I actually need that. So I have an idea…

I downloaded that DLL to myDocuments. I’m going to move it to my project directory instead and reference it from there.

HOLD THUMBS!

that worked!

THE SOLUTION:

Ladies and geeks, Do not reference a DLL from MyDocuments folder.

 

 

 

One thought on “WPF : Access to the path ‘C:\Users\Michael\Documents\My Music’ is denied.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s