Groups | Blog | Home
all groups > dotnet interop > september 2005 >

dotnet interop : Can't create COM object (VB6) in Web user control on WEBFORMS



Ton
9/29/2005 6:02:04 AM
Hi,
I've developed several Webuser controls. One of the controls is using a VB6
based activeX component. The code looks like:

Dim dbF As Object ''dbRecordFrm.dbRecordForm
If ses Is Nothing Then
ses = CreateObject("dbOLEserver.Session")
End If
dbF = CreateObject("dbRecordFrm.dbRecordForm")
On the last line I receive an error:
Server Error in '/WebApplication1' Application.
--------------------------------------------------------------------------------
Cannot create ActiveX component.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.
Exception Details: System.Exception: Cannot create ActiveX component.

If I restart my development PC It works fine for the fisttime. But a second
time fails. I've given the ASPNET- user administrator rights!
On all forms ASPCOM=True

Other COM objects don't have these problems, allthough I had the same
problems on other pc's, but these problems disapeared when I changed the
creation of the object from the NEW keyword to CREATEOBJECT.
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET
Version:1.1.4322.573

Thank you


Richard T. Edwards
10/3/2005 7:06:41 AM
Why does this sound oh, so familiar. Okay, if it works the first time but
not the second, it would appear that the first creation of the object
creates a the object under a specific user account.

When you add an additional reference to that object -- you have not set obj
references to nothing in VB6 world-- because the object is already up and
running either the permissions of the running object is locking you out or
the object can only be created once.

That's why, when you restart your machine, the object goes out of scope and
you can create it once again. It is also why, when you dropped the new
keyword and used createobject it worked.

Drop the typelib reference to these objects in your VB6 project and just use
createobject and see if that helps. Plus setting the objects to nothing will
help as well.


[quoted text, click to view]

Ton
10/3/2005 7:30:15 AM
what do you mean with:
Drop the typelib reference to these objects in your VB6 project and just use
createobject and see if that helps.

And second:
In he VB6 objects I do use the new keyword. Should I replace them with
creatobjects everywhere ?

thanx

ton
[quoted text, click to view]
AddThis Social Bookmark Button