p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   VS.NET 2002/2003 (http://p2p.wrox.com/forumdisplay.php?f=103)
-   -   Cannot create ActiveX component problem (http://p2p.wrox.com/showthread.php?t=12073)

cdukes77@bellsouth.net April 20th, 2004 03:41 PM

Cannot create ActiveX component problem
 
First, I'm a newbie to .Net ... Any help is appreciated.

So I see that one of the applications I frequently use (Adobe InDesign) can be driven using VB ... I decide to try it out ... if this works, there are many day-to-day work flow problems that I can address. First I try creating a VB executable (using Visual Studio .NET 2003) with a simple button ... the code behind the button is:


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        REM Hello World
        REM Declare variable types (optional if Option Explicit is off).
        Dim myInDesign As InDesign.Application
        Dim myDocument As InDesign.Document
        Dim myPage As InDesign.Page
        Dim myTextFrame As InDesign.TextFrame
        REM End of variable type declarations
        myInDesign = CreateObject("InDesign.Application.CS")
        REM Create a new document
        myDocument = myInDesign.Documents.Add
        REM Get a reference to the first page
        myPage = myDocument.Pages.Item(1)
        REM Create a text frame
        myTextFrame = myDocument.TextFrames.Add
        REM Specify the size and shape of the text frame
        Dim AryStringArray() As String = {"0p0", "0p0", "18p0", "18p0"}
        myTextFrame.GeometricBounds = AryStringArray
        REM Enter text in the text frame
        myTextFrame.Contents = "Hello World!"
    End Sub
End Class

(I added the Interop.InDesign reference to my project)

I compile and run it ... no problem, everything works ... cool ... then I decide to try the same thing from an aspx page ...

First I tried something simple and just copied and pasted the code into a button placed on an aspx page ... result when I tried the page in my browser ... "Cannot create ActiveX component "

I continued reading, and though nothing specifically said what the problem was I got the feeling there was a permission problem, someplace.

So ... tried creating a VB class (see code below):

Imports System
Imports InDesign

Namespace WroxUnited
    Public Class Class1
        Public Sub New()
        End Sub
        Public Function runInDesign()
            REM Hello World
            REM Declare variable types (optional if Option Explicit is off).
            Dim myInDesign As InDesign.Application
            Dim myDocument As InDesign.Document
            Dim myPage As InDesign.Page
            Dim myTextFrame As InDesign.TextFrame
            REM End of variable type declarations
            myInDesign = CreateObject("InDesign.Application.CS")
            REM Create a new document
            myDocument = myInDesign.Documents.Add
            REM Get a reference to the first page
            myPage = myDocument.Pages.Item(1)
            REM Create a text frame
            myTextFrame = myDocument.TextFrames.Add
            REM Specify the size and shape of the text frame
            Dim AryStringArray() As String = {"0p0", "0p0", "18p0", "18p0"}
            myTextFrame.GeometricBounds = AryStringArray
            REM Enter text in the text frame
            myTextFrame.Contents = "Hello World!"
            Return "Done"
        End Function
    End Class
End Namespace


... then calling the VB class from the button (see code below):

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim ClassTest As New WroxUnited.Class1
        Dim lblMessage
        lblMessage = ClassTest.runInDesign
    End Sub


Result when I tried to test ... ... "Cannot create ActiveX component " ...

Kept reading ... found a reference that indicated that the ASPNET user account might need to be given Administrator rights ...
tried that ... same result ...

I'm obviously missing something here, but I seem to see variants of the question from several other people. Any ideas?

I have gotten a hint that I may need to register an ActiveX object using the regsvr32.exe utility ... but the question is (if this is the answer) what ActiveX object.



planoie April 20th, 2004 07:02 PM

Normally when you want to use a COM (ActiveX) object in .net you need to use the interop for it. When you instantiate the object, you do so in the same way you do any other .net object:

        myInDesign = New InDesign.Application.CS

I'm not sure if that is the problem but it's worth looking into.

Peter
-------------------------
Work smarter, not harder

cdukes77@bellsouth.net April 21st, 2004 09:28 AM

Are you suggesting that...

myInDesign = New InDesign.Application.CS

should replace my ...

myInDesign = CreateObject("InDesign.Application.CS")

I tried this line in the code ... which then returns a new error (at least it is new) ...

System.Runtime.InteropServices.COMException: COM object with CLSID {296CAEB5-C99C-4B3E-9359-6E7D6EAE71FC} is either not valid or not registered.

Is there any way to proceed from here.

Thanks for your help.

Chip

Quote:

quote:Originally posted by planoie
 Normally when you want to use a COM (ActiveX) object in .net you need to use the interop for it. When you instantiate the object, you do so in the same way you do any other .net object:

        myInDesign = New InDesign.Application.CS

I'm not sure if that is the problem but it's worth looking into.

Peter
-------------------------
Work smarter, not harder

planoie April 21st, 2004 09:47 AM

Have you created a COM interop assembly for this ActiveX component? In Visual Studio.net when you set up a COM reference VS builds a COM Callable Wrapper (CCW) that handles the interaction between .net and COM. This should take care of some of the problem.

But it also sounds like the component isn't registered.

cdukes77@bellsouth.net April 22nd, 2004 01:06 AM

There is an interop resource for the code already ... what I'm trying to figure out is exactly what it s that needs to be registered? Remember this is all a little new for me.

BTW ... does the fact that everything worked properly when in a VB.NET executable mean that there IS A WAY to accomplish the same thing from within an asp page?

Chip

Quote:

quote:Originally posted by planoie
 Have you created a COM interop assembly for this ActiveX component? In Visual Studio.net when you set up a COM reference VS builds a COM Callable Wrapper (CCW) that handles the interaction between .net and COM. This should take care of some of the problem.

But it also sounds like the component isn't registered.

planoie April 22nd, 2004 08:35 AM

If it all worked in a windows forms application then you must have everything set up correctly. This leads to the suspicion that maybe there is a permissions issue coming into play. The ASP.net process runs under a different account than an EXE would run. I can't think of why this would happen though. What is the COM component doing that might be breaking because of permissions? Some kind of file operation?

Ryden June 2nd, 2004 03:44 AM

The reason for this is that the account IUSR_<computername> does not have enough permissions on your application's folder.
I just resolved this a minute ago by giving full permissions to the account, I will try to see exactly what permissions it really need but this is the basic solution.


rk325 June 18th, 2004 11:25 AM

Hi, I am having a similar problem.
I created a new component in VB6 to add to an existing VB6 application. It runs fine within the vb6 windows application. I even can call this component from a vbscript program, and from a VB.NET windows app, using on both cases CreateObject.
The component accesses a database and updates records on it.

But it breaks down when I call it from a web service application using CreateObject. The same error: Cannot create ActiveX component....

how do I check the IUSR_<computername> permissions? I cannot seem to find the Users & Passwords icon in Control Panels. I am running W2K SP4.



Quote:

quote:Originally posted by Ryden
 The reason for this is that the account IUSR_<computername> does not have enough permissions on your application's folder.
I just resolved this a minute ago by giving full permissions to the account, I will try to see exactly what permissions it really need but this is the basic solution.



Bor February 6th, 2006 01:30 PM

Hi there,

I have a similar problem with a web service in .net.

I have a CreateObject of the COM ASPIMAGE in a .net dll but this gives me a "Cannot Create Active X object" but a try other way... I have an ASP(VBScript) page with the same CREATEOBJECT and here i havent errors... Then i Run de web Service and... I have the COM reference???? I can use all methods of ASPIMAGE.

The problem its that if i dont use the webservice for 10 or 15 minutes a get the error and must run the asp again.

What happens here????

Sorry for my English, i wish you can understand me....


clazette April 6th, 2006 09:33 AM

I have the same issue and have pretty much given the world full control over the inetpub\wwwroot\app_directory and propagated those permissions to all sub-directories and I am still encountering the same error. I am not having an issue with a Windows App version of the same code implementation.

Thoughts?

Chad



All times are GMT -4. The time now is 10:52 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.