Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Store Interface variable in an Intraweb session

0 views
Skip to first unread message

David Uzzell

unread,
Jan 24, 2008, 5:13:08 PM1/24/08
to
Hello

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

Jason Southwell

unread,
Jan 24, 2008, 8:24:33 PM1/24/08
to
> 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.

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.


Doychin Bondzhev

unread,
Jan 25, 2008, 4:55:03 AM1/25/08
to
Another solution is to use second thread to talk to Excel spreadsheet,
that will open the connection. You will keep that thread live until
session is live.

You will need some sort of interface to talk to that thread when you
need some data from spreadsheet.

Doychin

Jason Southwell

unread,
Jan 25, 2008, 10:26:55 AM1/25/08
to
> You will need some sort of interface to talk to that thread when you
> need some data from spreadsheet.

Good idea. You will also need to protect that interface from multi-threaded
access.


David Uzzell

unread,
Feb 6, 2008, 7:35:19 PM2/6/08
to
I thought this was a good idea too. So I wrote and single-instance,
single-threaded, in-process COM server to act as a portal from the
webserver to Excel. When I moved the accessor functions from my previous
version to this app, only the functions that return an integer seem to
work. All of the functions that return a BSTR or a variant cause a fault
in RPCRT4.dll.

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

0 new messages