To start off, we have 2 servers: Alpha (Server 2008 R2) and Beta (Server 2008).
We cannot create images Beta using Microsoft.Ink.dll (we have version 1.7.2600.2180). The code works great on Alpha (Server 2008 R2) but on Beta (Server 2008) it fails. Our code is compiled in x86 and both server's app pools are set to allow x86 programs. Also, we have installed the Tablet SDK on beta to make sure we can generate images.
I created a desktop app to test the code that I am using and it works just fine (when compiled in x86). When we run the same code through a Web Service, it does not seem to work.
Why does Microsoft.Ink.Ink.Save() fail via IIS7, but not via a .EXE on Server 2008?
System.ArgumentException: Value does not fall within the expected range. at Microsoft.Ink.InkDispClass.Save(InkPersistenceFormat PersistenceFormat, InkPersistenceCompressionMode CompressionMode) at Microsoft.Ink.Ink.Save(PersistenceFormat p, CompressionMode c) at Microsoft.Ink.Ink.Save(PersistenceFormat p) at Signatures.GenerateSignatures.SignatureTest(String path)
This does not work in a Web Service Call on Server 2008 (not R2):
[WebMethod]
public string SignatureTest()
{
try
{
using (InkPicture tmpSignaturePicture = new InkPicture())
{
const string signature = "base64:AIICAwZIEUU1RjURAACAPx8JEQAAAAAAAPA/CucBXYfwu9eGRFQeVf5rCA4GZKyNkzI2BuAUoe0sm5K2forAuBOBXgOz9o6NwO4FlAKBo3aDJFEoDJGSskbQ2ho7gVtGZI2lwTrgWdF8E7QOATyTwCuj+AT2jtHgFck8E1ozgFOAUwJgbA2jNGcAlRNGYH0ZgWh0PA2B8DwCh7TonAK4HwOAh/BDl4HqaDQ9p0Rgdo+fz7JmCclYGoGSsCQDRWCNnZLgGBtp4GwPgWhZL0aaNwJknA2j9nwFkrRmjKFkrJFAwNgWhqGwPQqHkkyTgfAtFomioBgQwLQKDQMDAKDQGB8DFDoQ";
byte[] base64IsfBytes = Encoding.UTF8.GetBytes(signature);
tmpSignaturePicture.Ink.Load(base64IsfBytes);
if (!(tmpSignaturePicture.Ink.Strokes.GetBoundingBox().IsEmpty))
{
string thisFileName = "Signature" + "_" + Guid.NewGuid() + ".gif";
byte[] fortifiedGif = tmpSignaturePicture.Ink.Save(PersistenceFormat.Gif);
using (FileStream gifFile = File.OpenWrite(thisFileName))
{
gifFile.Write(fortifiedGif, 0, fortifiedGif.Length);
return thisFileName;
}
}
}
}
catch (Exception ex)
{
return ex.ToString();
}
return "fail";
}
The same code works in a desktop app on Server 2008 (not R2):
try
{
using (InkPicture tmpSignaturePicture = new InkPicture())
{
const string sig = "base64:AIICAwZIEUU1RjURAACAPx8JEQAAAAAAAPA/CucBXYfwu9eGRFQeVf5rCA4GZKyNkzI2BuAUoe0sm5K2forAuBOBXgOz9o6NwO4FlAKBo3aDJFEoDJGSskbQ2ho7gVtGZI2lwTrgWdF8E7QOATyTwCuj+AT2jtHgFck8E1ozgFOAUwJgbA2jNGcAlRNGYH0ZgWh0PA2B8DwCh7TonAK4HwOAh/BDl4HqaDQ9p0Rgdo+fz7JmCclYGoGSsCQDRWCNnZLgGBtp4GwPgWhZL0aaNwJknA2j9nwFkrRmjKFkrJFAwNgWhqGwPQqHkkyTgfAtFomioBgQwLQKDQMDAKDQGB8DFDoQ";
byte[] base64IsfBytes = Encoding.UTF8.GetBytes(sig);
tmpSignaturePicture.Ink.Load(base64IsfBytes);
if (!(tmpSignaturePicture.Ink.Strokes.GetBoundingBox().IsEmpty))
{
string thisFileName = "Signature" + "_" + Guid.NewGuid() + ".gif";
byte[] fortifiedGif = tmpSignaturePicture.Ink.Save(PersistenceFormat.Gif);
using (FileStream gifFile = File.OpenWrite(thisFileName))
{
gifFile.Write(fortifiedGif, 0, fortifiedGif.Length);
}
}
}
}
catch (Exception ex)
{
MessageBox.Show("Error" + Environment.NewLine + ex.ToString());
}