When I store an Interface variable in a session, I get an "Object not
connected to Server" error message when I try to re-use the interface
after the user has submitted a page.
In the debugger the variable appears to be present. Calling CoInitialize
just before reusing the variable tells me that COM is already
initialized. The COM objects constructor is not called after the user
submits the page, so I think I'm working with the same, live object that
I created and used before dispatching the page.
The COM object is an Excel spreadsheet running on the server.
Any ideas about what I may be doing wrong?
Thanks
David
It may be that excel does not like the thread context changing when you go
back to access it the second time. If you haven't tried it, try setting
your cominitialize property to ciMultithreaded which should account for this.
But even with ciMultithreaded, some apps can't handle the fact that you
opened the COM connection in one thread and then are accessing it from another.
You may have to reconnect each time you want to use it.
You will need some sort of interface to talk to that thread when you
need some data from spreadsheet.
Doychin
Good idea. You will also need to protect that interface from multi-threaded
access.
I've tried multi-instancing and apartment-threading just to make sure
they weren't the issue. They're not.
Can you make any kind of sense out of this? Is it paranoid of me to
suspect that these difficulties with Excel are due to Microsoft design?
Thanks
David