dotnet/maui · error · ArgumentException
No file exists at "{0}"
Error message
No file exists at "{0}" What it means
Verify.FileExists throws ArgumentException when File.Exists(filePath) returns false. It combines IsNeitherNullNorEmpty on the path with a filesystem existence check, so the message formats the offending path. It is a precondition guard for APIs that require a real file on disk.
Source
Thrown at src/Compatibility/Core/src/WPF/Microsoft.Windows.Shell/Standard/Verify.cs:297
Verify.IsNotNull(type, "type");
Verify.IsNotNull(interfaceType, "interfaceType");
if (type.GetInterface(interfaceType.Name) == null)
{
Assert.Fail();
throw new ArgumentException("The type of this parameter does not support a required interface", parameterName);
}
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DebuggerStepThrough]
public static void FileExists(string filePath, string parameterName)
{
Verify.IsNeitherNullNorEmpty(filePath, parameterName);
if (!File.Exists(filePath))
{
Assert.Fail();
throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "No file exists at \"{0}\"", filePath), parameterName);
}
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DebuggerStepThrough]
internal static void ImplementsInterface(object parameter, Type interfaceType, string parameterName)
{
Assert.IsNotNull(parameter);
Assert.IsNotNull(interfaceType);
Assert.IsTrue(interfaceType.IsInterface);
bool isImplemented = false;
foreach (var ifaceType in parameter.GetType().GetInterfaces())
{
if (ifaceType == interfaceType)
{
isImplemented = true;
break;View on GitHub (pinned to f377ff1c5e)
Solutions
- Verify File.Exists(path) at the call site before invoking the API.
- Resolve paths to absolute with Path.GetFullPath and log the resolved path for debugging.
- Check the deployment package includes the file and the working directory is correct.
Example fix
// before
loader.Load(templatePath); // file may not exist
// after
var fullPath = Path.GetFullPath(templatePath);
if (!File.Exists(fullPath))
{
throw new FileNotFoundException($"Template not found: {fullPath}", fullPath);
}
loader.Load(fullPath); Defensive patterns
Strategy: validation
Validate before calling
// Pre-check: file must exist
var fullPath = Path.GetFullPath(filePath);
if (!File.Exists(fullPath))
{
throw new FileNotFoundException($"File not found: {fullPath}", fullPath);
}
SomeApi(fullPath); Prevention
- Resolve paths to absolute with Path.GetFullPath and log them for debugging.
- Verify the working directory is correct before file operations.
- Ensure deployment packages include all required files.
When it happens
Trigger: Calling a method guarded by Verify.FileExists(filePath, paramName) where the file does not exist at the given path. The guard fires before any attempt to open or read the file.
Common situations: Relative path resolved against the wrong working directory; missing deployment artifact; user-supplied path with a typo; file deleted between a prior check and the call; path environment differences between dev and production.
Related errors
- The parameter cannot be either null or empty.
- The parameter cannot be either null or empty or consist only
- The parameter must not be the default value.
- The parameter must be null.
- The URI must be absolute.
AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13).
Data as JSON: /api/errors/3c863a1e3023d532.
Report an issue: GitHub.