It seems that the first time you call the AddExtension method, it will automatically add a filename with the "tmp" extension to the collection before then trying to add the filename with your specified extension.
So if you specify "tmp" as the extension then it will try to add the same file twice, causing the exception.
using (var tfc = new TempFileCollection())
{
var foo = tfc.AddExtension("foo");
var bar = tfc.AddExtension("bar");
foreach (var f in tfc)
{
Console.WriteLine(f);
}
}
The above code will generate the following output. Notice that it includes a filename with the "tmp" extension that we didn't explicitly add.
C:\Users\Luke\AppData\Local\Temp\jmat4jqg.tmp
C:\Users\Luke\AppData\Local\Temp\jmat4jqg.bar
C:\Users\Luke\AppData\Local\Temp\jmat4jqg.foo