1

I have a aspx web forms project, and am using a Silverlight component to acquire images through a scanner on the client side, once the scan is complete I need to send two byte arrays to the aspx session variable, so I can save these byte arrays against a record.

I currently am just trying to send a basic string from Silverlight to aspx to try and update the session variable (Trying to get the basics working, before stepping it up)

I get a NullReferenceException though when I try to update the session variable, and get a response from the WebService saying "NotFound"...

Here is what I now have:

Web Service:

namespace XXXX
{
/// <summary>
/// Summary description for EnrollService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService]
public class EnrollService : System.Web.Services.WebService
{

    [WebMethod]
    public void SetSessionEmpIDs(string Templates)
    {
        Session.Add("EmployeeIDs", Templates);
    }
}
}

Silverlight side:

EnrollServiceReference.EnrollServiceSoapClient client = new EnrollServiceReference.EnrollServiceSoapClient();
client.SetSessionEmpIDs("IDsDONE");
John Saunders
  • 160,644
  • 26
  • 247
  • 397
BFG
  • 387
  • 1
  • 3
  • 14
  • Almost all cases of `NullReferenceException` are the same. Please see "[What is a NullReferenceException in .NET?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-in-net)" for some hints. – John Saunders Oct 08 '13 at 13:53

1 Answers1

0

Try to send byte[] array chunks (~ 1024 bytes or more, you need to figure out the optimal size for your configuration/client environment) of the file and assemble them on server - it's more viable and flexible approach ('vector array' chunks file representation is more natural + service bindings/channels have sended/received data size restrictions).

And I don't recommend using Object and Interface WCF method parameter/return type AT ALL, because this can lead to incompatibility with some clients (according to WS-standards/specs)

SalientBrain
  • 2,431
  • 16
  • 18
  • Hi @SalientBrain, Thank you for your comment, I have however since the post run into other issues with just getting the basics of a Web Service working, perhaps you can help with that? – BFG Oct 08 '13 at 13:37
  • Hi SalientBrain and @John Saunders, I have found a work around, other than using sessions variables for now (Although I am faced with another issue- New Post), as I have spent WAY to much time on this task... I may revisit this in the future,but thank you both for your comments. For the record I do not see how Session Variables can ever be updated through a service, as the service has NO reference to which users Session Variable to access (And I believe that is why the NullReference) I however may be proven wrong in the future. – BFG Oct 08 '13 at 14:44