The given path's format is not supported.

D

David

I am having a problem reading files, on some systems, when running as
a windows service. The same code, run as an executable works just
fine. On my system it works. On a co-workers it doesn't. Same OS
(2000Pro).

The service is logged on as "LocalSystem".

I've seen similar posts, but I've yet to see an appropriate answer.
The file name is built from DirectoryInfo and FileInfo details, so the
format should be fine.

Written in C#, using .NET 1.1.


I 3Dec03 01:06:43.140: FLS 0 Reading file
[C:/Creo/FeatureLicensing/Database/demo.cll.xml]
E 3Dec03 01:06:43.156: FLS 0 System.NotSupportedException: The given
path's format is not supported.
at System.Security.Util.StringExpressionSet.CanonicalizePath(String
path, Boolean needFullPath)
at System.Security.Util.StringExpressionSet.AddExpressions(String[]
str, Boolean checkForDuplicates, Boolean needFullPath)
at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess
access, String[] pathListOrig, Boolean checkForDuplicates, Boolean
needFullPath, Boolean copyPathList)
at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess
access, String[] pathList, Boolean checkForDuplicates, Boolean
needFullPath)
at System.IO.Path.GetFullPath(String path)
at System.CodeDom.Compiler.TempFileCollection.EnsureTempNameCreated()
at System.CodeDom.Compiler.TempFileCollection.AddExtension(String
fileExtension, Boolean keepFile)
at System.CodeDom.Compiler.TempFileCollection.AddExtension(String
fileExtension)
at System.CodeDom.Compiler.CodeCompiler.FromSourceBatch(CompilerParameters
options, String[] sources)
at System.CodeDom.Compiler.CodeCompiler.FromSource(CompilerParameters
options, String source)
at System.CodeDom.Compiler.CodeCompiler.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromSource(CompilerParameters
options, String source)
at System.Xml.Serialization.Compiler.Compile()
at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[]
xmlMappings)
at System.Xml.Serialization.XmlSerializer..ctor(Type type, String
defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type)


Any help appreciated.

Thanks,
David
 
D

Dmitriy Lapshin [C# / .NET MVP]

Hi David,

First try to use the backward slash (\) as a path separator. The forward
slash character is not typical for the Windows platform and can cause
problems.
 
D

David

Good point, but changing that didn't help. Still craps out as a
service, but not executable.

I 10Dec03 01:43:35.546: FLS 0 Reading CVF file
[C:\Creo\FeatureLicensing\Database\demo.cvf.xml]
E 10Dec03 01:43:35.562: FLS 0 System.NotSupportedException: The given
path's format is not supported.
at System.Security.Util.StringExpressionSet.CanonicalizePath(String
path, Boolean needFullPath)
at System.Security.Util.StringExpressionSet.AddExpressions(String[]
str, Boolean checkForDuplicates, Boolean needFullPath)
at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess
access, String[] pathListOrig, Boolean



Dmitriy Lapshin said:
Hi David,

First try to use the backward slash (\) as a path separator. The forward
slash character is not typical for the Windows platform and can cause
problems.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

David said:
I am having a problem reading files, on some systems, when running as
a windows service. The same code, run as an executable works just
fine. On my system it works. On a co-workers it doesn't. Same OS
(2000Pro).

The service is logged on as "LocalSystem".

I've seen similar posts, but I've yet to see an appropriate answer.
The file name is built from DirectoryInfo and FileInfo details, so the
format should be fine.

Written in C#, using .NET 1.1.


I 3Dec03 01:06:43.140: FLS 0 Reading file
[C:/Creo/FeatureLicensing/Database/demo.cll.xml]
E 3Dec03 01:06:43.156: FLS 0 System.NotSupportedException: The given
path's format is not supported.
at System.Security.Util.StringExpressionSet.CanonicalizePath(String
path, Boolean needFullPath)
at System.Security.Util.StringExpressionSet.AddExpressions(String[]
str, Boolean checkForDuplicates, Boolean needFullPath)
at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAcc
ess
access, String[] pathListOrig, Boolean checkForDuplicates, Boolean
needFullPath, Boolean copyPathList)
at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess
access, String[] pathList, Boolean checkForDuplicates, Boolean
needFullPath)
at System.IO.Path.GetFullPath(String path)
at System.CodeDom.Compiler.TempFileCollection.EnsureTempNameCreated()
at System.CodeDom.Compiler.TempFileCollection.AddExtension(String
fileExtension, Boolean keepFile)
at System.CodeDom.Compiler.TempFileCollection.AddExtension(String
fileExtension)
at System.CodeDom.Compiler.CodeCompiler.FromSourceBatch(CompilerParameters
options, String[] sources)
at System.CodeDom.Compiler.CodeCompiler.FromSource(CompilerParameters
options, String source)
at System.CodeDom.Compiler.CodeCompiler.System.CodeDom.Compiler.ICodeCompiler.C
ompileAssemblyFromSource(CompilerParameters
options, String source)
at System.Xml.Serialization.Compiler.Compile()
at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[]
xmlMappings)
at System.Xml.Serialization.XmlSerializer..ctor(Type type, String
defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type)


Any help appreciated.

Thanks,
David
 
D

Dmitriy Lapshin [C# / .NET MVP]

The problem is most likely caused by the CanonicalizePath method. Do MSDN
docs say something about any specific requirements for this method?

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

David said:
Good point, but changing that didn't help. Still craps out as a
service, but not executable.

I 10Dec03 01:43:35.546: FLS 0 Reading CVF file
[C:\Creo\FeatureLicensing\Database\demo.cvf.xml]
E 10Dec03 01:43:35.562: FLS 0 System.NotSupportedException: The given
path's format is not supported.
at System.Security.Util.StringExpressionSet.CanonicalizePath(String
path, Boolean needFullPath)
at System.Security.Util.StringExpressionSet.AddExpressions(String[]
str, Boolean checkForDuplicates, Boolean needFullPath)
at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAcc
ess
access, String[] pathListOrig, Boolean



"Dmitriy Lapshin [C# / .NET MVP]" <[email protected]> wrote
in message news: said:
Hi David,

First try to use the backward slash (\) as a path separator. The forward
slash character is not typical for the Windows platform and can cause
problems.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

David said:
I am having a problem reading files, on some systems, when running as
a windows service. The same code, run as an executable works just
fine. On my system it works. On a co-workers it doesn't. Same OS
(2000Pro).

The service is logged on as "LocalSystem".

I've seen similar posts, but I've yet to see an appropriate answer.
The file name is built from DirectoryInfo and FileInfo details, so the
format should be fine.

Written in C#, using .NET 1.1.


I 3Dec03 01:06:43.140: FLS 0 Reading file
[C:/Creo/FeatureLicensing/Database/demo.cll.xml]
E 3Dec03 01:06:43.156: FLS 0 System.NotSupportedException: The given
path's format is not supported.
at System.Security.Util.StringExpressionSet.CanonicalizePath(String
path, Boolean needFullPath)
at System.Security.Util.StringExpressionSet.AddExpressions(String[]
str, Boolean checkForDuplicates, Boolean needFullPath)
at
System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAcc
ess
access, String[] pathListOrig, Boolean checkForDuplicates, Boolean
needFullPath, Boolean copyPathList)
at
System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess
access, String[] pathList, Boolean checkForDuplicates, Boolean
needFullPath)
at System.IO.Path.GetFullPath(String path)
at System.CodeDom.Compiler.TempFileCollection.EnsureTempNameCreated()
at System.CodeDom.Compiler.TempFileCollection.AddExtension(String
fileExtension, Boolean keepFile)
at System.CodeDom.Compiler.TempFileCollection.AddExtension(String
fileExtension)
at System.CodeDom.Compiler.CodeCompiler.FromSourceBatch(CompilerParameters
options, String[] sources)
at System.CodeDom.Compiler.CodeCompiler.FromSource(CompilerParameters
options, String source)
at
System.CodeDom.Compiler.CodeCompiler.System.CodeDom.Compiler.ICodeCompiler.C
ompileAssemblyFromSource(CompilerParameters
options, String source)
at System.Xml.Serialization.Compiler.Compile()
at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[]
xmlMappings)
at System.Xml.Serialization.XmlSerializer..ctor(Type type, String
defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type)


Any help appreciated.

Thanks,
David
 
M

mikeb

David said:
Good point, but changing that didn't help. Still craps out as a
service, but not executable.

I 10Dec03 01:43:35.546: FLS 0 Reading CVF file
[C:\Creo\FeatureLicensing\Database\demo.cvf.xml]
E 10Dec03 01:43:35.562: FLS 0 System.NotSupportedException: The given
path's format is not supported.
at System.Security.Util.StringExpressionSet.CanonicalizePath(String
path, Boolean needFullPath)
at System.Security.Util.StringExpressionSet.AddExpressions(String[]
str, Boolean checkForDuplicates, Boolean needFullPath)
at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess
access, String[] pathListOrig, Boolean

What are the permissions for the file
"C:\Creo\FeatureLicensing\Database\demo.cvf.xml"? Does LocalSystem have
access?

Generally LocalSystem (which shows up as SYSTEM in explorer's ACL
editor) has full access, but it's possible for that access to be
removed. When you run the code as a standard executable, it runs under
the logged on user's identity, who might have access rights to the file
that SYSTEM does not have.

Then again, I'd expect a different error in that case - I'm just
guessing here.
Dmitriy Lapshin said:
Hi David,

First try to use the backward slash (\) as a path separator. The forward
slash character is not typical for the Windows platform and can cause
problems.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

I am having a problem reading files, on some systems, when running as
a windows service. The same code, run as an executable works just
fine. On my system it works. On a co-workers it doesn't. Same OS
(2000Pro).

The service is logged on as "LocalSystem".

I've seen similar posts, but I've yet to see an appropriate answer.
The file name is built from DirectoryInfo and FileInfo details, so the
format should be fine.

Written in C#, using .NET 1.1.


I 3Dec03 01:06:43.140: FLS 0 Reading file
[C:/Creo/FeatureLicensing/Database/demo.cll.xml]
E 3Dec03 01:06:43.156: FLS 0 System.NotSupportedException: The given
path's format is not supported.
at System.Security.Util.StringExpressionSet.CanonicalizePath(String
path, Boolean needFullPath)
at System.Security.Util.StringExpressionSet.AddExpressions(String[]
str, Boolean checkForDuplicates, Boolean needFullPath)
at
System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAcc
ess

access, String[] pathListOrig, Boolean checkForDuplicates, Boolean
needFullPath, Boolean copyPathList)
at
System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess

access, String[] pathList, Boolean checkForDuplicates, Boolean
needFullPath)
at System.IO.Path.GetFullPath(String path)
at System.CodeDom.Compiler.TempFileCollection.EnsureTempNameCreated()
at System.CodeDom.Compiler.TempFileCollection.AddExtension(String
fileExtension, Boolean keepFile)
at System.CodeDom.Compiler.TempFileCollection.AddExtension(String
fileExtension)
at
System.CodeDom.Compiler.CodeCompiler.FromSourceBatch(CompilerParameters

options, String[] sources)
at System.CodeDom.Compiler.CodeCompiler.FromSource(CompilerParameters
options, String source)
at
System.CodeDom.Compiler.CodeCompiler.System.CodeDom.Compiler.ICodeCompiler.C
ompileAssemblyFromSource(CompilerParameters

options, String source)
at System.Xml.Serialization.Compiler.Compile()
at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[]
xmlMappings)
at System.Xml.Serialization.XmlSerializer..ctor(Type type, String
defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type)


Any help appreciated.

Thanks,
David
 
D

David

Update/solution:

Finally tracked it down. Briefly, the System TMP environment variable
was poorly formed!

In detail:

I was calling XmlSerializer() which, if we follow the stack trace,
needs to compile code, presumably based on the object type I pass to
it. Way down in the bowels of the stack it needs to make a temporary
file to write to. It must be getting the temporary path through a
similar call as Path.GetTempFileName(). If the TEMP/TMP environment
variable is BAD, the call fails and all you get is "The given path's
format is not supported.", which is refering to the internal temporary
name, not any name I was using.

The issue only presented itself, because when run under a user account
it uses the envirnment variable set under the "User variable for xxx"
section of the "Environment Variables" dialog. When running as a
service, it uses the settings under the "System variables" section.
What was happening was the System TMP variable was badly formed;
"C:\temp;C:\WINNT\TEMP". Someone had mistakenly set the variable as if
it was a path list, rather than a discrete directory path. Changing
the variable back to "C:\WINNT\TEMP" fixed the problem.

It's unfortunate that the .NET framework is relying internally on a
user configuration setting that could be invalid. To be fair, I had
other software behave poorly when I changed my TMP variable to be bad,
in testing the scenario.


David

mikeb said:
David said:
Good point, but changing that didn't help. Still craps out as a
service, but not executable.

I 10Dec03 01:43:35.546: FLS 0 Reading CVF file
[C:\Creo\FeatureLicensing\Database\demo.cvf.xml]
E 10Dec03 01:43:35.562: FLS 0 System.NotSupportedException: The given
path's format is not supported.
at System.Security.Util.StringExpressionSet.CanonicalizePath(String
path, Boolean needFullPath)
at System.Security.Util.StringExpressionSet.AddExpressions(String[]
str, Boolean checkForDuplicates, Boolean needFullPath)
at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess
access, String[] pathListOrig, Boolean

What are the permissions for the file
"C:\Creo\FeatureLicensing\Database\demo.cvf.xml"? Does LocalSystem have
access?

Generally LocalSystem (which shows up as SYSTEM in explorer's ACL
editor) has full access, but it's possible for that access to be
removed. When you run the code as a standard executable, it runs under
the logged on user's identity, who might have access rights to the file
that SYSTEM does not have.

Then again, I'd expect a different error in that case - I'm just
guessing here.
Dmitriy Lapshin said:
Hi David,

First try to use the backward slash (\) as a path separator. The forward
slash character is not typical for the Windows platform and can cause
problems.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE


I am having a problem reading files, on some systems, when running as
a windows service. The same code, run as an executable works just
fine. On my system it works. On a co-workers it doesn't. Same OS
(2000Pro).

The service is logged on as "LocalSystem".

I've seen similar posts, but I've yet to see an appropriate answer.
The file name is built from DirectoryInfo and FileInfo details, so the
format should be fine.

Written in C#, using .NET 1.1.


I 3Dec03 01:06:43.140: FLS 0 Reading file
[C:/Creo/FeatureLicensing/Database/demo.cll.xml]
E 3Dec03 01:06:43.156: FLS 0 System.NotSupportedException: The given
path's format is not supported.
at System.Security.Util.StringExpressionSet.CanonicalizePath(String
path, Boolean needFullPath)
at System.Security.Util.StringExpressionSet.AddExpressions(String[]
str, Boolean checkForDuplicates, Boolean needFullPath)
at

System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAcc
ess

access, String[] pathListOrig, Boolean checkForDuplicates, Boolean
needFullPath, Boolean copyPathList)
at

System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess

access, String[] pathList, Boolean checkForDuplicates, Boolean
needFullPath)
at System.IO.Path.GetFullPath(String path)
at System.CodeDom.Compiler.TempFileCollection.EnsureTempNameCreated()
at System.CodeDom.Compiler.TempFileCollection.AddExtension(String
fileExtension, Boolean keepFile)
at System.CodeDom.Compiler.TempFileCollection.AddExtension(String
fileExtension)
at

System.CodeDom.Compiler.CodeCompiler.FromSourceBatch(CompilerParameters

options, String[] sources)
at System.CodeDom.Compiler.CodeCompiler.FromSource(CompilerParameters
options, String source)
at

System.CodeDom.Compiler.CodeCompiler.System.CodeDom.Compiler.ICodeCompiler.C
ompileAssemblyFromSource(CompilerParameters

options, String source)
at System.Xml.Serialization.Compiler.Compile()
at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[]
xmlMappings)
at System.Xml.Serialization.XmlSerializer..ctor(Type type, String
defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type)


Any help appreciated.

Thanks,
David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top