473,516 Members | 3,456 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

'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

Nov 17 '05 #1
7 9977
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 http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #2
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" <na***@dao2com.com> wrote in message
news:OH**************@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 http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #3
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 http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #4
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" <na***@dao2com.com> wrote in message
news:eR*************@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 http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #5
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 http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #6
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" <na***@dao2com.com> wrote in message
news:OP**************@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 http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #7
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:OL*************@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

Nov 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
15739
by: brazilnut | last post by:
Hi. Let me explain the setup. I am using Visual Studio .NET to develop a sort of add-in (COM class) for Excel called SQLAddin. It basically queries a SQL server and pulls in data. Now within my Visual Studio Project, the SQLAddin references a compiled COM object built with Visual Studio 6.0 called SQLOld.dll. When I complie the project I get the...
2
13375
by: brazilnut52 | last post by:
I am going to outline the steps I go through to produce the problem. Hopefully this will help you understand the problem better I have created a simple COM DLL in .NET by using the COM class template and by setting output to a type library (DLL). All the object does is return a string value. At this point I have not checked the option to...
1
8611
by: Craig | last post by:
I am having problems getting an ActiveX DLL written in VB6 to call a method in a C# class library component. My C# DLL is called CSharpProject.dll and contains a public class called CSharpClass. In this class is a single public method that returns the string "Hello from C sharp". My VB6 ActiveX DLL references the C# DLL...
5
8754
by: andy.g.ward | last post by:
I keep getting this when trying to create an MFC activex control in a c# windows service - anyone got any ideas what the missing module could be??? Exception thrown : System.IO.FileNotFoundException: The specified module could not be found. at System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(Guid& clsid, Object punkOuter, Int32...
1
3098
by: Mehr H | last post by:
I have been working on this for several days and am still have had no success in achieving this. Pleae help. It seems that documentation for this is very limited. I have looked in several books and they all seem to say either nothing about this or that this is "out of the scope of this book", even "Professional ASP.NET". I have a ActiveX...
4
2244
by: FanTian | last post by:
I want to insert an ActiveX control into asp .net web page, but it seems I fall in trouble now. When I insert the ocx control into toolbox and drag it to the web page, I can't get its ID. and if I use the interop dll transformed with aximp.exe from the ocx, I can't insert it into the tool box. who can tell me what to do? Thanks a lot!
3
2504
by: Jeffery Franzen | last post by:
Anyone know where the documentation is regarding Activex controls in asp web forms? I'm using VS.NET 2002 enterprise and am trying to use Activex controls in vb.net web form app. I do the add control to pallete and then add a reference. I get the interop dll added to bin folder. I did this with the MediaPlayer activex control as a simple...
23
3423
by: Galen Somerville | last post by:
A VB6 ActiveX.exe raises an event which is seen by the VB6 App. Same setup in VB2005. The event to be raised is in form frmSweep. As in VB6, frmSweep is hidden when the events take place. I know by actions on the screen and sounds in the speakers that VB2005 is using the ActiveX.exe correctly. However the events are never raised !!!
3
7861
by: Lou | last post by:
I know I can make an ActiveX dll in .NET and it uses interop. So I end up with 2 files, the .dll and the interop file. I also know I need to use Regasm or something like that to register the .dll as a COM object. Am I right so far? lets say I create a VB6 app and want to use the .NET dll. Does the installer of the VB6 app have to register...
0
7273
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7182
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7405
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7136
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5712
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3265
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3252
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
487
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.