Search code examples
c#visual-studio-2010windows-server-2012

Why does Application.LocalUserAppDataPath throw System.NotSupportedException?


In our environment we development boxes in several flavors of Windows Desktop (7 & 8). Our build server is Windows Server 2012 R2. When we build one of our applications on a developer machine it builds and runs just fine on any system (Windows 7, 8, and 2012). When we build on the build server (2012), it builds fine, but does not run on any system (Windows 7, 8, or 2012).

In debugging (on the 2012 system), I find that Application.LocalUserAppDataPath is throwing a System.NotSupportedException.

Any clues on why that might be happening?

I have seen elsewhere noted that if the running user does not have a profile, LocalUserAppDataPath will throw an exception. However, the user we are building (and running my tests) with does have a profile.


Solution

  • The answer is that the path built in this situation was a bad path.

    The build machine had automated information added to the assembly information files. I was unaware of the use of the AssemblyCompany element in building paths. The contents of this element was incorrect as a path (contained a ":" character).

    Props to David A. White for pointing to the reference code which also contains instructions on debugging the .NET code. This allowed me to see the problem.