'ActiveX can't create object' error with COM Interop...

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default 'ActiveX can't create object' error with COM Interop...

    Hi,

    I've built a webservice in C# that can add public folders to Exchange.
    There's also a component built in VB6 which references the Outlook 10 (XP)
    DLL, so I can change the default form being used to post to a public folder.
    The component works fine when instantiated from a Windows script, but when
    using it from COM Interop in an ASP.NET web application it errors when
    trying to execute oNs.GetNameSpace("MAPI").

    The error it throws up is 'ActiveX cant create object'. This sounds like a
    permissions issue, so I changed web.config and IIS to make the ASP.NET web
    application impersonate the administrator account, but without any luck.

    A sample of my VB6 code:
    (The project references cdo.dll and msoutl.olb)

    Public Function UpdateFolder()

    'Declare variables
    Dim objSession As New MAPI.Session
    Dim oFolderA As Outlook.mapiFolder
    Dim oFolderTmp As Outlook.mapiFolder
    Dim oFolderB As MAPI.Folder
    Dim oOutlook As New Outlook.Application
    Dim oNs As Outlook.NameSpace
    Dim tmpFolder As Outlook.mapiFolder

    'Get items from Outlook
    Set oNs = oOutlook.GetNamespace("MAPI")

    'More stuff here, but taken out to keep this example short.
    'The line above is where it hangs.

    End Function


    The DLL is referenced in my Web Application, and is called using the
    following:

    Project1.Class1 Obj = new Project1.Class1();
    Obj.UpdateFolder();

    The VB6 component uses MAPI which I know can't be used from ASP.NET due to
    issues with threading, but I don't think this is causing it, as it's all in
    the VB6 component (which was built to get around the problem of it not
    working in .net).

    If this can't be done, then I might have to write a Windows service, which
    is called by the webservice, and invokes the VB6 component method to change
    the default form. Or maybe find a way of executing a Windows Script from
    ASP.NET (something which I've had no joy with so far). Both these methods
    are long ways of doing it, and which I'd like to avoid if possible.

    Any help is appreciated. Cheers.

    Mun



    Munsifali Rashid Guest

  2. Similar Questions and Discussions

    1. Error: 429 ActiveX Component Can't create Object
      Hi all, I have Adobe Acrobat Professional 7.0 installed on an NT Server. Now, the question is, can I use its objects in an intranet ASP...
    2. ActiveX component can't create object
      I'm having problems setting up a monstrous COM+ Frankenapp on my local machine. The application works on the development server when I access it...
    3. Help on this error -- ActiveX component can't create object
      I got this error on the new environment. It works on the old environment. New: window 2003 server. iis 6.0, Microsoft visual basic 6.0. old:...
    4. Activex component can't create object error
      Well Tony, you are right. at start up I get this error:cannot load DLL - and this gets highlighted: Set dbs = CurrentDb() But, as I said,...
    5. Error:: Activex componet can not create object:"WScript.Shell"
      I am trying to use the shell object to send keys to the explorer browser to run the send page funcion. I am receiving the above error only when I...
  3. #2

    Default Re: 'ActiveX can't create object' error with COM Interop...

    Hi,

    1) I hope you use tlbimp and you are working against the .NET assembly
    that tlbimp create.

    2) did you add Impersonate=true in your web.config to accomplish
    impersonating of IIS settings ?

    Natty Gur, CTO
    Dao2Com Ltd.
    28th Baruch Hirsch st. Bnei-Brak
    Israel , 51114

    Phone Numbers:
    Office: +972-(0)3-5786668
    Fax: +972-(0)3-5703475
    Mobile: +972-(0)58-888377

    Know the overall picture


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur Guest

  4. #3

    Default Re: 'ActiveX can't create object' error with COM Interop...

    Hi,

    Thanks for the response.

    I added the reference to my project in VS.NET using the 'Add Reference'
    option. Does this automatically create the .net assembly or do I have to
    use tlbimp to create this manually?

    Yep, I did add <identity impersonate = "true" /> in web.config so that the
    ..net web application uses the credentials passed to it from IIS rather than
    it's own ASPNET account.

    Mun




    "Natty Gur" <natty@dao2com.com> wrote in message
    news:OHRxReBUDHA.2512@TK2MSFTNGP10.phx.gbl...
    > Hi,
    >
    > 1) I hope you use tlbimp and you are working against the .NET assembly
    > that tlbimp create.
    >
    > 2) did you add Impersonate=true in your web.config to accomplish
    > impersonating of IIS settings ?
    >
    > Natty Gur, CTO
    > Dao2Com Ltd.
    > 28th Baruch Hirsch st. Bnei-Brak
    > Israel , 51114
    >
    > Phone Numbers:
    > Office: +972-(0)3-5786668
    > Fax: +972-(0)3-5703475
    > Mobile: +972-(0)58-888377
    >
    > Know the overall picture
    >
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    Munsifali Rashid Guest

  5. #4

    Default Re: 'ActiveX can't create object' error with COM Interop...

    No, use tlbimp and make reference to the output assembly.

    Natty Gur, CTO
    Dao2Com Ltd.
    28th Baruch Hirsch st. Bnei-Brak
    Israel , 51114

    Phone Numbers:
    Office: +972-(0)3-5786668
    Fax: +972-(0)3-5703475
    Mobile: +972-(0)58-888377

    Know the overall picture


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur Guest

  6. #5

    Default Re: 'ActiveX can't create object' error with COM Interop...

    Tried it, and I get the same error. The command I used was tlbimp
    project1.dll /out:project1_interop.dll /namespace:project1. Then I added
    reference project1_interop.dll (tlbimp created file) rather than
    project1.dll (VB6 compiled file).

    It still throws up the 'ActiveX cant create object' error when I call Set
    oNs = oOutlook.GetNameSpace("MAPI") command (Where oOutlook is New
    Outlook.Application).

    Looks like I'm gonna have to find a different way of making this work :-/

    Thanks for your help.

    Mun



    "Natty Gur" <natty@dao2com.com> wrote in message
    news:eRbg0sCUDHA.556@TK2MSFTNGP12.phx.gbl...
    > No, use tlbimp and make reference to the output assembly.
    >
    > Natty Gur, CTO
    > Dao2Com Ltd.
    > 28th Baruch Hirsch st. Bnei-Brak
    > Israel , 51114
    >
    > Phone Numbers:
    > Office: +972-(0)3-5786668
    > Fax: +972-(0)3-5703475
    > Mobile: +972-(0)58-888377
    >
    > Know the overall picture
    >
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    Munsifali Rashid Guest

  7. #6

    Default Re: 'ActiveX can't create object' error with COM Interop...

    Just a thought, if you try to call the COM object directly (via vbs
    file) is it working ?

    Natty Gur, CTO
    Dao2Com Ltd.
    28th Baruch Hirsch st. Bnei-Brak
    Israel , 51114

    Phone Numbers:
    Office: +972-(0)3-5786668
    Fax: +972-(0)3-5703475
    Mobile: +972-(0)58-888377

    Know the overall picture


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur Guest

  8. #7

    Default Re: 'ActiveX can't create object' error with COM Interop...

    Yep, if I create a windows script (VBS) file it works fine:

    Dim Obj: Set Obj = CreateObject("Project1.Class1")
    Call Obj.UpdateFolder()
    Set Obj = Nothing

    I'm looking into it now, and it's gotta be something with permissions. I'm
    thinking about trying it in a COM+ application... I've created another
    simple component in VB6 which calls the GetNameSpace method. If I call this
    from an ASP.NET application it throws up the error, but if I call it from a
    C# Windows Application, it works fine.

    I thought it might be caused if the ASPNET account didn't have permissions
    to access the Outlook DLL (msoutl.olb), but I've given everyone permisisons
    to that file and it still doesn't work. Maybe the GetNameSpace method is
    reference from another DLL which doesn't have permissions.

    But then again, I'm forcing the Web Application to impersonate the
    Administrator's account anyway, so permissions can't be an issue. This
    one's got me a bit puzzled...

    Mun




    "Natty Gur" <natty@dao2com.com> wrote in message
    news:OPfbsvDUDHA.2220@TK2MSFTNGP11.phx.gbl...
    > Just a thought, if you try to call the COM object directly (via vbs
    > file) is it working ?
    >
    > Natty Gur, CTO
    > Dao2Com Ltd.
    > 28th Baruch Hirsch st. Bnei-Brak
    > Israel , 51114
    >
    > Phone Numbers:
    > Office: +972-(0)3-5786668
    > Fax: +972-(0)3-5703475
    > Mobile: +972-(0)58-888377
    >
    > Know the overall picture
    >
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    Munsifali Rashid Guest

  9. #8

    Default Re: 'ActiveX can't create object' error with COM Interop...

    I think I've worked out why it's happening, but not a solution.

    The code relies on Outlook to do the MAPI related stuff, and also on Outlook
    having an account registered which has acccess to public folders (i.e. using
    the mail icon in control panel). I.e. If no mail profile exists in Outlook,
    the code breaks, as it can't access the public folders to do what its gotta
    do.

    When I run my component using an application or a Windows Script, it's using
    the interactive user, which is why it works - Outlook has a profile set up.
    With the Web Application, despite using impersonation, only permissions are
    being impersonated, but when the component loads Outlook and tries to get
    the MAPI namespace, it can't because it doesn't exist - as no mail profile
    exists in Outlook.

    Now I've just gotta test this by removing the profile from Outlook for the
    interactive user, and then running the code to see if it throws up the same
    error in the same place.

    Mun





    "Munsifali Rashid" <mun@**RemoveToReply**vefuk.com> wrote in message
    news:OLktpBEUDHA.560@TK2MSFTNGP10.phx.gbl...
    > Yep, if I create a windows script (VBS) file it works fine:
    >
    > Dim Obj: Set Obj = CreateObject("Project1.Class1")
    > Call Obj.UpdateFolder()
    > Set Obj = Nothing
    >
    > I'm looking into it now, and it's gotta be something with permissions.
    I'm
    > thinking about trying it in a COM+ application... I've created another
    > simple component in VB6 which calls the GetNameSpace method. If I call
    this
    > from an ASP.NET application it throws up the error, but if I call it from
    a
    > C# Windows Application, it works fine.
    >
    > I thought it might be caused if the ASPNET account didn't have permissions
    > to access the Outlook DLL (msoutl.olb), but I've given everyone
    permisisons
    > to that file and it still doesn't work. Maybe the GetNameSpace method is
    > reference from another DLL which doesn't have permissions.
    >
    > But then again, I'm forcing the Web Application to impersonate the
    > Administrator's account anyway, so permissions can't be an issue. This
    > one's got me a bit puzzled...
    >
    > Mun
    >

    Munsifali Rashid Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139