I have WebService:
public class Service1:WebService {
private readonly MNConnection _conn;
private MNLpu _lpu;
public Service1() {
_conn = new MNConnection();
}
[WebMethod(EnableSession = true)]
public void Open(string login, string password) {
_conn.Open(login, password);
_lpu = (MNLpu)_conn.CreateLPU();
}
[WebMethod(EnableSession = true)]
public decimal Get() {
return _lpu.Count;
}
}
When I call it's from external console application, it's show me NullReferenceException on last line:
CookieContainer cookie = new CookieContainer();
Service1 lh = new Service1 {CookieContainer = cookie};
lh.Open("login", "pwd");
Console.WriteLine(lh.Get());
If remove Open() method from webservice and insert to constructor such lines it's works fine:
_conn.Open(login, password);
_lpu = (MNLpu)_conn.CreateLPU();
How to fix it? P.S. MNConnection - my own class, which works with OracleConnection.