FileInfo..ctor(string fileName) throwing exception: bug in SL 4.0 or .NET 4.0?

Posted by Duncan Bayne on Stack Overflow See other posts from Stack Overflow or by Duncan Bayne
Published on 2010-03-15T00:19:21Z Indexed on 2010/03/15 0:29 UTC
Read the original article Hit count: 588

Filed under:
|

The following test case passes in .NET 4.0:

var fiT = new FileInfo("myhappyfilename");
Assert.IsNotNull(fiT);

... but fails in Silverlight 4.0 with the following error:

System.ArgumentNullException: Value cannot be null.
Parameter name: format
   at System.String.Format(IFormatProvider provider, String format, Object[] args)
   at System.Environment.GetResourceString(String key, Object[] values)
   at System.IO.FileSecurityState.EnsureState()
   at System.IO.FileInfo.Init(String fileName, Boolean checkHost)
   at System.IO.FileInfo..ctor(String fileName)

Either the failure is a bug in SL 4.0, or the non-failure is a bug in .NET 4.0. Anyone know which it is?

(For the record, I'm running SL 4.0 on VS 2010 RC, which may be contributing to the problem).

© Stack Overflow or respective owner

Related posts about .net-4.0

Related posts about silverlight-4.0