Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 1.0 and Visual Studio.NET > VS.NET 2002/2003
|
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 20th, 2004, 03:41 PM
Registered User
 
Join Date: Apr 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.


 
Old April 20th, 2004, 07:02 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

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
 
Old April 21st, 2004, 09:28 AM
Registered User
 
Join Date: Apr 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
 
Old April 21st, 2004, 09:47 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

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.
 
Old April 22nd, 2004, 01:06 AM
Registered User
 
Join Date: Apr 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
 
Old April 22nd, 2004, 08:35 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

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?
 
Old June 2nd, 2004, 03:44 AM
Registered User
 
Join Date: Jun 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

 
Old June 18th, 2004, 11:25 AM
Registered User
 
Join Date: Jun 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

 
Old February 6th, 2006, 01:30 PM
Bor Bor is offline
Registered User
 
Join Date: Feb 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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....

 
Old April 6th, 2006, 09:33 AM
Registered User
 
Join Date: Apr 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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






Similar Threads
Thread Thread Starter Forum Replies Last Post
ActiveX Component cannot create Object Madhivanan VB How-To 5 December 23rd, 2006 02:33 AM
ActiveX Component can't create an object lihar Access VBA 1 December 20th, 2006 07:52 AM
cannot create activex component - help please cobweb Classic ASP Components 1 September 14th, 2006 08:40 PM
Cannot create ActiveX Component Ron Howerton Pro VB.NET 2002/2003 0 July 18th, 2006 10:33 AM
ActiveX component can't create object lameneural Classic ASP Components 0 July 4th, 2006 12:14 AM





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