objectdisposedexception

ASP.Net Entity Framework, objectcontext error

て烟熏妆下的殇ゞ 提交于 2019-11-28 07:13:38
问题 I'm building a 4 layered ASP.Net web application. The layers are: Data Layer Entity Layer Business Layer UI Layer The entity layer has my data model classes and is built from my entity data model (edmx file) in the datalayer using T4 templates (POCO). The entity layer is referenced in all other layers. My data layer has a class called SourceKeyRepository which has a function like so: public IEnumerable<SourceKey> Get(SourceKey sk) { using (dmc = new DataModelContainer()) { var query = from

What could be causing a “Cannot access a disposed object” error in WCF?

一笑奈何 提交于 2019-11-27 22:54:52
I am using the following code: private WSHttpBinding ws; private EndpointAddress Srv_Login_EndPoint; private ChannelFactory<Srv_Login.Srv_ILogin> Srv_LoginChannelFactory; private Srv_Login.Srv_ILogin LoginService; The Login is my constructor: public Login() { InitializeComponent(); ws = new WSHttpBinding(); Srv_Login_EndPoint = new EndpointAddress("http://localhost:2687/Srv_Login.svc"); Srv_LoginChannelFactory = new ChannelFactory<Srv_Login.Srv_ILogin>(ws, Srv_Login_EndPoint); } And I'm using service this way: private void btnEnter_Click(object sender, EventArgs e) { try { LoginService = Srv

ObjectDisposedException when closing SerialPort in .Net 2.0

╄→гoц情女王★ 提交于 2019-11-27 14:01:39
问题 I have a C# windows forms application which communicates with a USB dongle via a COM port. I am using the SerialPort class in .Net 2.0 for communication, and the serial port object is open for the lifetime of the application. The application sends commands to the device and can also receive unsolicited data from the device. My problem occurs when the form is closed - I get (randomly, unfortunately) an ObjectDisposedException when attempting to close the COM port. Here is the Windows stack

What could be causing a “Cannot access a disposed object” error in WCF?

我的未来我决定 提交于 2019-11-26 21:13:47
问题 I am using the following code: private WSHttpBinding ws; private EndpointAddress Srv_Login_EndPoint; private ChannelFactory<Srv_Login.Srv_ILogin> Srv_LoginChannelFactory; private Srv_Login.Srv_ILogin LoginService; The Login is my constructor: public Login() { InitializeComponent(); ws = new WSHttpBinding(); Srv_Login_EndPoint = new EndpointAddress("http://localhost:2687/Srv_Login.svc"); Srv_LoginChannelFactory = new ChannelFactory<Srv_Login.Srv_ILogin>(ws, Srv_Login_EndPoint); } And I'm using