CreateObject fails AND works

  • Thread starter Thread starter dlasusa
  • Start date Start date
D

dlasusa

Sorry if this is the wrong group...I THINK I got to the right
place...(oh...and I'm a newbie programmer...so please be gentle)

Anyway I have a program that works fine when I run it from within
VS2005 (no errors and does exactly what it should)

BUT if I build it and then try to run the .exe on the same computer it
fails with:

"Unhandled exception...."

"Cannot create ActiveX component"

It seems to fail on this line:

objAdminSystem = CreateObject("NovellGroupWareAdmin")

I added the reference to this object (Name: Groupwise Admin API
Library) (Filename: Interop.AdminTypeLibrary.dll)

I did some searching online and found someone had fixed it by running
"regsvr32 gwcmb1.dll"

I tried that (it suceeded) but the program still fails outside of the
VS2005 environment.

Thanks for any help you might be able to provide!
 
Dim objAdminSystem As New NovellGroupWareAdmin()

instead of

objAdminSystem = CreateObject("NovellGroupWareAdmin")
 
I tried what you suggested and got:

Type 'NovellGroupWareAdmin' is not defined.

That sounds like it should be an easy thing to fix, but so far I've had
no luck.

Thank you for helping!
 
Well, when you made the reference to the object library, the classes in that
library are now available to your code, BUT in .NET you won't be able to
call a class without referring to the namespace the class resides in. I had
assumed you had already imported the namespace, but perhaps you haven't.

You will need to know what the namespace name is that your class is in. You
can then add an "Imports" statement to your code and then you can make your
instance as I've shown.

In .NET, we do not use the CreateObject method for object instantition.
 
Ok...so I'm new to using usenet too....so forgive me if I screw this posting
to the group up...a simple smack in the right direction and I'll correct my
mistake...

As for the problem...

I *think* I DID import the namespace (but obviously not right? :-)

I Added a reference first to "GroupWare Admin Type library" and when it
still didn't work I added a reference to "GroupWare Type Library"

I've also added two imports statements (in addition to the reference in the
project)

Imports AdminTypeLibrary

Imports GroupwareTypeLibrary


What I don't understand is why it works perfectly when I use the little
green arrow inside of VS2005...but when I run the app from the
built/deployed (not sure which is the right word) .exe file it fails.

You also mentioned we no longer use "CreateObject," after my woes...I'm all
for using something else :-) what SHOULD I be using?

Oh...I also added the line that is failing to a Try...Catch....to see if
there was more info and found that I'm getting:

System.Exception: Cannot create ActiveX component.
at Microsoft.VisualBasic.Interaction.CreateObject(String ProgID, String
ServerName) at.....<location info>

I should also mention...this code was originally written in VS2003...and
converted UP.

I also WAS running both VS2003 and 2005 at the same time and just this
afternoon uninstalled 2003.

Am I helping or just making this all more confusing?
Hope it's the first!
 
See responses below:


Moose said:
Ok...so I'm new to using usenet too....so forgive me if I screw this
posting
to the group up...a simple smack in the right direction and I'll correct
my
mistake...

No, your posting is fine, no probelms there. :)
As for the problem...

I *think* I DID import the namespace (but obviously not right? :-)

I Added a reference first to "GroupWare Admin Type library" and when it
still didn't work I added a reference to "GroupWare Type Library"

I've also added two imports statements (in addition to the reference in
the
project)

Imports AdminTypeLibrary

Imports GroupwareTypeLibrary


What I don't understand is why it works perfectly when I use the little
green arrow inside of VS2005...but when I run the app from the
built/deployed (not sure which is the right word) .exe file it fails.

Silly question, but when you deployed this application to its final
location, did you copy the Groupware .dll's and the InterOp .dll's?
You also mentioned we no longer use "CreateObject," after my woes...I'm
all
for using something else :-) what SHOULD I be using?

CreateObject was how instances of classes were made in the predecessor to
ASP.NET (classic ASP & VBScript).
The correct way to make instances is what I showed you earlier

Dim someVariable As New someClass

Oh...I also added the line that is failing to a Try...Catch....to see if
there was more info and found that I'm getting:

System.Exception: Cannot create ActiveX component.
at Microsoft.VisualBasic.Interaction.CreateObject(String ProgID, String
ServerName) at.....<location info>

That's good, but the exception information doesn't tell us much more than we
already knew in this case.
I should also mention...this code was originally written in VS2003...and
converted UP.

I don't think this has too much to do with the issue.
I also WAS running both VS2003 and 2005 at the same time and just this
afternoon uninstalled 2003.

There is no problem with having both installed at the same time. They each
use different versions of the.NET Framework and both those versions are made
to co-exist simultaneously. The only thing to be carefull about is that
when you open a 2003 project in 2005, it will be automatically converted to
the 2.0 framework and there's no going back after that, so you should make
backups of all your 2003 projects in case you want to preserve that code.
Am I helping or just making this all more confusing?
Hope it's the first!

No, we just need to keep digging to find the problem.
 
Sorry if this double posts....I THOUGHT I posted this 2 days ago, but
never saw it show up....

My response is inline below....

Silly question, but when you deployed this application to its final
location, did you copy the Groupware .dll's and the InterOp .dll's?

Response:

Currently, the final location is still my local machine. I did some
searching and see there are multiple debug and release directories
(I'm assuming setup by VS2005). Here are the contents of those folders
(Project name is GW_troubleshooting):

GW_troubleshooting\bin\Debug>
11/04/2003 11:17 AM 557,108 GWCMB1.dll
10/15/2006 10:07 PM 32,768 GW_troubleshooting.exe
10/15/2006 10:07 PM 65,024 GW_troubleshooting.pdb
09/23/2005 06:56 AM 5,632 GW_troubleshooting.vshost.exe
10/15/2006 10:07 PM 126 GW_troubleshooting.xml
10/13/2006 08:45 AM 155,648 Interop.AdminTypeLibrary.dll
10/13/2006 03:35 PM 688,128 Interop.GroupwareTypeLibrary.dll

GW_troubleshooting\bin\Release>
10/13/2006 03:35 PM 28,672 GW_troubleshooting.exe
10/13/2006 03:35 PM 60,928 GW_troubleshooting.pdb
10/13/2006 03:35 PM 126 GW_troubleshooting.xml
10/13/2006 03:31 PM 155,648 Interop.AdminTypeLibrary.dll
10/13/2006 03:31 PM 688,128 Interop.GroupwareTypeLibrary.dll

GW_troubleshooting\obj\Debug>
10/15/2006 10:07 PM 32,768 GW_troubleshooting.exe
10/13/2006 03:35 PM 180
GW_troubleshooting.Form1.resources
10/15/2006 10:07 PM 65,024 GW_troubleshooting.pdb
10/13/2006 03:35 PM 180
GW_troubleshooting.Resources.resources
10/13/2006 09:08 AM 842
GW_troubleshooting.vbproj.GenerateResource.Cache
10/13/2006 03:35 PM 541
GW_troubleshooting.vbproj.ResolveComReference.cache
10/15/2006 10:07 PM 126 GW_troubleshooting.xml
10/13/2006 08:45 AM 155,648 Interop.AdminTypeLibrary.dll
10/13/2006 03:35 PM 688,128 Interop.GroupwareTypeLibrary.dll
10/13/2006 10:24 AM <DIR> TempPE

GW_troubleshooting\obj\Release>
10/15/2006 09:53 PM 0 build.force
10/13/2006 03:35 PM 28,672 GW_troubleshooting.exe
10/13/2006 03:31 PM 180
GW_troubleshooting.Form1.resources
10/13/2006 03:35 PM 60,928 GW_troubleshooting.pdb
10/13/2006 03:31 PM 180
GW_troubleshooting.Resources.resources
10/13/2006 03:31 PM 842
GW_troubleshooting.vbproj.GenerateResource.Cache
10/13/2006 03:31 PM 541
GW_troubleshooting.vbproj.ResolveComReference.cache
10/13/2006 03:35 PM 126 GW_troubleshooting.xml
10/13/2006 03:31 PM 155,648 Interop.AdminTypeLibrary.dll
10/13/2006 03:31 PM 688,128 Interop.GroupwareTypeLibrary.dll
10/13/2006 03:24 PM <DIR> TempPE

GW_troubleshooting\My Project>
10/13/2006 08:37 AM 1,519 Application.Designer.vb
10/13/2006 08:37 AM 510 Application.myapp
10/13/2006 08:37 AM 1,217 AssemblyInfo.vb
10/13/2006 08:37 AM 2,804 Resources.Designer.vb
09/23/2005 03:27 AM 5,612 Resources.resx
10/13/2006 08:37 AM 3,054 Settings.Designer.vb
09/23/2005 03:27 AM 279 Settings.settings

Honestly, I'm not sure what the different folders are for :-/

Here is my code...

Imports AdminTypeLibrary
Imports GroupwareTypeLibrary

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim PO, Dom As String
Dim objDomain, objDom, objPOs, objPO, objCurPO As Object
Dim objdlists, objdlist
Dim DomPath As String = "T:\GRPWISE\DOMAIN"

PO = "<PO String>"
Dom = "<Domain>"

Try
Dim objAdminSystem As Object
'Dim objAdminSystem As New NovellGroupWareAdmin() - Had
tried that.
objAdminSystem = CreateObject("NovellGroupWareAdmin")
<------------fails here per error, but works when running it in the
VS2005 environment
objDomain = objAdminSystem.Connect("T:\GRPWISE\DOMAIN")

'Connect to Default Domain
objDom = objAdminSystem.ConnectedDomain

'Get the Post Offices collection
objPOs = objDom.PostOffices

'Enumerate the Post Offices on objPOs and populate cbPOs.
For Each objPO In objPOs
objCurPO = objPO
Next

objdlists = objCurPO.distributionlists

For Each objdlist In objdlists
lbGWDlist.Items.Add(objdlist.Name)
Next
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try


End Sub

-----End Code-----

The only thing I can really add to this...is when I look in the
registry and some other searching online....I think I remember reading
that "NovellGroupWareAdmin" is called from GWCMB1.dll. (and I added it
manually to ..."bin\Debug" directory)

here is a screenshot of the references:

http://img.villagephotos.com/p/2004-8/797417/GWts_references.jpg

Any idea what I'm messing up?
 
Ok, well you are using VB.NET 2005 (which I haven't used yet), but I have a
couple of things....

It looks like you've made references to the InterOp versions of the original
COM .dlls for GroupWare & AdminTypeLibrary. Did you make the references to
the InterOp files or the original .dll's? You should NOT be referencing the
InterOp files. VS.NET will create the InterOp files and call them as
needed.

Second, if there is a .dll that needs "GWCMB1.dll" and GWCMB1.dll is a COM
..dll, then you can't just move it into your /bin folder. It must be
registered with the Windows Registry and located in a particular location (I
don't know what that is).

-Scott
 
Back
Top