Hello,
I am developing a webservice that uses a third party dll. The dll
works when i use it offline but when i deploy it into the webservice
and use a client to call it, it stops working (no error message
though). I added the dll as a reference in the offline part and the
webservice.
The offline code:
//simpel method to open a image and convert it to a byte[] (needed by
a webservice)
private void button1_Click(o bject sender, EventArgs e)
{
string dir = System.Environm ent.CurrentDire ctory;
if (openFileDialog 1.ShowDialog() == DialogResult.OK )
{
System.Environm ent.CurrentDire ctory = dir;
string ImageFilename = openFileDialog1 .FileName;
FileStream fs = new FileStream(Imag eFilename,
FileMode.OpenOr Create, FileAccess.Read );
Byte[] img = new Byte[fs.Length];
fs.Read(img, 0, Convert.ToInt32 (fs.Length));
Rec(img);
//Rec(ms.GetBuffe r());
}
else
System.Environm ent.CurrentDire ctory = dir;
}
//uses the dll (DataMatrixDeco der) and returns the decoded message
private void Rec(byte[] img)
{
System.IO.Memor yStream ms = new
System.IO.Memor yStream(img);
System.Drawing. Bitmap b =
(System.Drawing .Bitmap)Image.F romStream(ms);
b.Save("test2.b mp", ImageFormat.Bmp );
DataMatrixDecod er DMDec = new DataMatrixDecod er();
string ret = "";
foreach (string s in DataMatrixDecod er.DecodeBarcod e(b))
ret += s + " ";
textBox1.Text += ret;
}
The webservice code (its similar to the rec function of the offline
part):
[WebMethod]
public string DecodeImage(byt e[] img)
{
System.IO.Memor yStream ms = new System.IO.Memor yStream(img);
System.Drawing. Bitmap b =
(System.Drawing .Bitmap)Image.F romStream(ms);
DataMatrixDecod er DMDec = new DataMatrixDecod er();
string ret = "";
foreach (string s in DataMatrixDecod er.DecodeBarcod e(b))
ret += s + " ";
return ret;
}
The cliend code (similar to the button1_Click of the offline part):
private void button1_Click(o bject sender, EventArgs e)
{
openFileDialog1 = new OpenFileDialog( );
if(openFileDial og1.ShowDialog( )== DialogResult.OK )
{
string file = openFileDialog1 .FileName;
FileStream fs = new FileStream(file ,
FileMode.OpenOr Create, FileAccess.Read );
Byte[] img = new Byte[fs.Length];
fs.Read(img, 0, Convert.ToInt32 (fs.Length));
localhost.Servi ce ser= new localhost.Servi ce();
tests+= ser.DecodeImage (img);
textBox1.Text = tests;
}
}
I use the same image in the offline part as in the online part. when i
run the online part it returns the right decoded string, but when i
try the webservice-client one it returns a empty string. The image
arrives fine, because its the same when i save it on the server as the
one i send it.
I am trying this using visual 2005 and iis 5. So could this be caused
by some configuration error in iis (don't know much about iis), like
something has to be changed to let the dll run. (i tried with a test
dll and that worked fine, so the dll's do load into memory).
Any thoughts? help would be much appreciated sinc"e i been stuck on
this problem quite a while.
I am developing a webservice that uses a third party dll. The dll
works when i use it offline but when i deploy it into the webservice
and use a client to call it, it stops working (no error message
though). I added the dll as a reference in the offline part and the
webservice.
The offline code:
//simpel method to open a image and convert it to a byte[] (needed by
a webservice)
private void button1_Click(o bject sender, EventArgs e)
{
string dir = System.Environm ent.CurrentDire ctory;
if (openFileDialog 1.ShowDialog() == DialogResult.OK )
{
System.Environm ent.CurrentDire ctory = dir;
string ImageFilename = openFileDialog1 .FileName;
FileStream fs = new FileStream(Imag eFilename,
FileMode.OpenOr Create, FileAccess.Read );
Byte[] img = new Byte[fs.Length];
fs.Read(img, 0, Convert.ToInt32 (fs.Length));
Rec(img);
//Rec(ms.GetBuffe r());
}
else
System.Environm ent.CurrentDire ctory = dir;
}
//uses the dll (DataMatrixDeco der) and returns the decoded message
private void Rec(byte[] img)
{
System.IO.Memor yStream ms = new
System.IO.Memor yStream(img);
System.Drawing. Bitmap b =
(System.Drawing .Bitmap)Image.F romStream(ms);
b.Save("test2.b mp", ImageFormat.Bmp );
DataMatrixDecod er DMDec = new DataMatrixDecod er();
string ret = "";
foreach (string s in DataMatrixDecod er.DecodeBarcod e(b))
ret += s + " ";
textBox1.Text += ret;
}
The webservice code (its similar to the rec function of the offline
part):
[WebMethod]
public string DecodeImage(byt e[] img)
{
System.IO.Memor yStream ms = new System.IO.Memor yStream(img);
System.Drawing. Bitmap b =
(System.Drawing .Bitmap)Image.F romStream(ms);
DataMatrixDecod er DMDec = new DataMatrixDecod er();
string ret = "";
foreach (string s in DataMatrixDecod er.DecodeBarcod e(b))
ret += s + " ";
return ret;
}
The cliend code (similar to the button1_Click of the offline part):
private void button1_Click(o bject sender, EventArgs e)
{
openFileDialog1 = new OpenFileDialog( );
if(openFileDial og1.ShowDialog( )== DialogResult.OK )
{
string file = openFileDialog1 .FileName;
FileStream fs = new FileStream(file ,
FileMode.OpenOr Create, FileAccess.Read );
Byte[] img = new Byte[fs.Length];
fs.Read(img, 0, Convert.ToInt32 (fs.Length));
localhost.Servi ce ser= new localhost.Servi ce();
tests+= ser.DecodeImage (img);
textBox1.Text = tests;
}
}
I use the same image in the offline part as in the online part. when i
run the online part it returns the right decoded string, but when i
try the webservice-client one it returns a empty string. The image
arrives fine, because its the same when i save it on the server as the
one i send it.
I am trying this using visual 2005 and iis 5. So could this be caused
by some configuration error in iis (don't know much about iis), like
something has to be changed to let the dll run. (i tried with a test
dll and that worked fine, so the dll's do load into memory).
Any thoughts? help would be much appreciated sinc"e i been stuck on
this problem quite a while.