WScript.CreateObject: Requirements for object? 
Author Message
 WScript.CreateObject: Requirements for object?

I have written (in C++ using ATL) a COM object.
When I try to create it with WScript.CreateObject()
I get an error, something like "Could not connect object"
with an error code of 0x80020009.  I tried to debug
my object to see if I could determine why WSCRIPT
was getting this error.  But I could not.
I could see all the QueryInterface calls (I think) and thus
determine what COM interfaces WSCRIPT was asking
for.  I believe my simple object satisfied all of them.

But I still get this error and have no clue about how to
figure out why I'm getting it.

Does anyone know how to debug this situation or
can you point me at a document that describes the
minimum set of interfaces  that must be provided by
an object to work with WScript.CreateObject()?

Thanks,
Sam Quiring



Fri, 04 Apr 2003 03:00:00 GMT  
 WScript.CreateObject: Requirements for object?
Hello Sam,

Looks like you got the wrong prog id this has to match exactly.

Did you do the Project with the ATL wizard?

Rob



Sat, 05 Apr 2003 03:00:00 GMT  
 WScript.CreateObject: Requirements for object?

I am pretty sure I have the right prog id.  I tried
both "test.obj1.1" and "test.obj1", names that were
in my registration.

I built the project with the ATL wizard.  Last night
I built a new object using the ATL wizard.  I built
the most vanilla object possible.  Nothing added.
Just whatever is built by the wizard.

I get the same error with this object as with my
simple test case.



Sat, 05 Apr 2003 03:00:00 GMT  
 WScript.CreateObject: Requirements for object?
I am pretty sure I have the right prog id.  I tried
both "test.obj1.1" and "test.obj1", names that were
in my registration file and in my registry.

I built the project with the ATL wizard.  Last night
I built a new object using the ATL wizard.  I built
the most vanilla object possible.  Nothing added.
Just whatever is built by the wizard.

I get the same error with this object as with my
simple test case.

Can you get this simple case to work?

===================

Quote:
> Hello Sam,

> Looks like you got the wrong prog id this has to match exactly.

> Did you do the Project with the ATL wizard?

> Rob



Sat, 05 Apr 2003 03:00:00 GMT  
 WScript.CreateObject: Requirements for object?


Quote:
> I am pretty sure I have the right prog id.  I tried
> both "test.obj1.1" and "test.obj1", names that were
> in my registration.

> I built the project with the ATL wizard.  Last night
> I built a new object using the ATL wizard.  I built
> the most vanilla object possible.  Nothing added.
> Just whatever is built by the wizard.

> I get the same error with this object as with my
> simple test case.

Hmm... I don't know what to tell you then. I do the
exact same thing, and it works.

Open C++

New Project

ATL AppWizard, project name "Test"

DLL, no special options (no MFC, etc)

Right-click on "Test Classes" project classes,
New ATL Object, Simple Object, class name: obj1

Add new Method:
  DoHelloWorld
Parameters:
  VARIANT *vStr

STDMETHODIMP Cobj1::DoHelloWorld(VARIANT *vStr)
{
 VariantInit(vStr);
 CComBSTR bstr("Hello, World!");
 V_VT(vStr) = VT_BSTR;
 vStr->bstrVal = bstr.Copy();

 return S_OK;

Quote:
}

Compile, rinse, repeat.

Now, the vbs code:

'------------------
Dim to1
Dim s1

Set to1 = CreateObject("Test.Obj1")

s1 = "yadda, yadda"

to1.DoHelloWorld s1

MsgBox s1
'------------------

(message box pops up with "Hello, World!")

-Chad



Sat, 05 Apr 2003 03:00:00 GMT  
 WScript.CreateObject: Requirements for object?

Chad,

Sam is using WScript.CreateObject...

Try:

'------------------
Dim to1
Dim s1

Set to1 = WScript.CreateObject("Test.Obj1")

s1 = "yadda, yadda"

to1.DoHelloWorld s1

MsgBox s1
'------------------

It _should_ work just the same, assuming this is the syntax Sam is using.

Now try:

Set to1 = WScript.CreateObject("Test.Obj1","foo_")

and (I think) you'll get the "...could not connect..." error because the object doesn't expose any
events.

--
Michael Harris
Microsoft.MVP.Scripting
--

Quote:



> > I am pretty sure I have the right prog id.  I tried
> > both "test.obj1.1" and "test.obj1", names that were
> > in my registration.

> > I built the project with the ATL wizard.  Last night
> > I built a new object using the ATL wizard.  I built
> > the most vanilla object possible.  Nothing added.
> > Just whatever is built by the wizard.

> > I get the same error with this object as with my
> > simple test case.

> Hmm... I don't know what to tell you then. I do the
> exact same thing, and it works.

> Open C++

> New Project

> ATL AppWizard, project name "Test"

> DLL, no special options (no MFC, etc)

> Right-click on "Test Classes" project classes,
> New ATL Object, Simple Object, class name: obj1

> Add new Method:
>   DoHelloWorld
> Parameters:
>   VARIANT *vStr

> STDMETHODIMP Cobj1::DoHelloWorld(VARIANT *vStr)
> {
>  VariantInit(vStr);
>  CComBSTR bstr("Hello, World!");
>  V_VT(vStr) = VT_BSTR;
>  vStr->bstrVal = bstr.Copy();

>  return S_OK;
> }

> Compile, rinse, repeat.

> Now, the vbs code:

> '------------------
> Dim to1
> Dim s1

> Set to1 = CreateObject("Test.Obj1")

> s1 = "yadda, yadda"

> to1.DoHelloWorld s1

> MsgBox s1
> '------------------

> (message box pops up with "Hello, World!")

> -Chad



Sat, 05 Apr 2003 03:00:00 GMT  
 WScript.CreateObject: Requirements for object?
Here are two lines from my .the .rgs file in my ATL project:

   ProgID = s 'Test1.Obj1.1'
   VersionIndependentProgID = s 'Test1.Obj1

Here's the line in my .vbs file that is getting the error:

set o1 = Wscript.CreateObject("Test1.Obj1.1", "TestObj1_")

The exact error box reads:

Script:   C:\tmp\atl\test1\test1.vbs
Line:      30
Char:      1
Error:      Could not connect object.
Code:      80020009
Source     WScript.CreateObject


Quote:
> Hello Sam,

> Looks like you got the wrong prog id this has to match exactly.

> Did you do the Project with the ATL wizard?

> Rob



Sat, 05 Apr 2003 03:00:00 GMT  
 WScript.CreateObject: Requirements for object?

Quote:
>    ProgID = s 'Test1.Obj1.1'
>    VersionIndependentProgID = s 'Test1.Obj1

> Here's the line in my .vbs file that is getting the error:
> set o1 = Wscript.CreateObject("Test1.Obj1.1", "TestObj1_")

AH.
So i think you sould use it like this:

set objadr = Wscript.CreateObject("Test1.Obj1")

if you did an project like you wrote then you have to build the objadr
without the location
i think the location is only for DCOM apps you can creat objects over
the network.

Alternativly you could use it with the version number but this is
normally only needed when
you more than one version and to acces an old version you must creat it
like this.
set objadr = Wscript.CreateObject("Test1.Obj1.1")

And you can even write:
set objadr = CreateObject("Test1.Obj1.1")
because in script unknown function calls are searched in the host of
wsricpt.

Robert



Sun, 06 Apr 2003 03:00:00 GMT  
 WScript.CreateObject: Requirements for object?
Quote:
> Set to1 = WScript.CreateObject("Test.Obj1","foo_")

> and (I think) you'll get the "...could not connect..." error because the

object doesn't expose any

Quote:
> events

The object has to expose events?  Is this documented somewhere?
Regardless, that is the correct answer.  When I rebuilt my object so
it had connection points (I think that's right) and added an event, then
it worked.

Thanks again for your help, Michael Harris.


Quote:

> Chad,

> Sam is using WScript.CreateObject...

> Try:

> '------------------
> Dim to1
> Dim s1

> Set to1 = WScript.CreateObject("Test.Obj1")

> s1 = "yadda, yadda"

> to1.DoHelloWorld s1

> MsgBox s1
> '------------------

> It _should_ work just the same, assuming this is the syntax Sam is using.

> Now try:

> Set to1 = WScript.CreateObject("Test.Obj1","foo_")

> and (I think) you'll get the "...could not connect..." error because the

object doesn't expose any

- Show quoted text -

Quote:
> events.

> --
> Michael Harris
> Microsoft.MVP.Scripting
> --




> > > I am pretty sure I have the right prog id.  I tried
> > > both "test.obj1.1" and "test.obj1", names that were
> > > in my registration.

> > > I built the project with the ATL wizard.  Last night
> > > I built a new object using the ATL wizard.  I built
> > > the most vanilla object possible.  Nothing added.
> > > Just whatever is built by the wizard.

> > > I get the same error with this object as with my
> > > simple test case.

> > Hmm... I don't know what to tell you then. I do the
> > exact same thing, and it works.

> > Open C++

> > New Project

> > ATL AppWizard, project name "Test"

> > DLL, no special options (no MFC, etc)

> > Right-click on "Test Classes" project classes,
> > New ATL Object, Simple Object, class name: obj1

> > Add new Method:
> >   DoHelloWorld
> > Parameters:
> >   VARIANT *vStr

> > STDMETHODIMP Cobj1::DoHelloWorld(VARIANT *vStr)
> > {
> >  VariantInit(vStr);
> >  CComBSTR bstr("Hello, World!");
> >  V_VT(vStr) = VT_BSTR;
> >  vStr->bstrVal = bstr.Copy();

> >  return S_OK;
> > }

> > Compile, rinse, repeat.

> > Now, the vbs code:

> > '------------------
> > Dim to1
> > Dim s1

> > Set to1 = CreateObject("Test.Obj1")

> > s1 = "yadda, yadda"

> > to1.DoHelloWorld s1

> > MsgBox s1
> > '------------------

> > (message box pops up with "Hello, World!")

> > -Chad



Mon, 07 Apr 2003 03:00:00 GMT  
 WScript.CreateObject: Requirements for object?
Michael Harris suggested that it wasn't working because
my object did not have any events.  He was correct.
I rebuilt the object to expose events and it worked fine.
So the problem is solved thanks to Mr. Harris.

I tried both the names below, "Test1.Obj1.1" and just
"Test1.Obj1".  Both worked.  I am pretty sure the intent
here is you use "Test1.Obj1" and as you create new versions
of the object, e.g., Test1.Obj1.1, Test1.Obj1.2, ..., you'll
always get the latest version.


Quote:
> >    ProgID = s 'Test1.Obj1.1'
> >    VersionIndependentProgID = s 'Test1.Obj1

> > Here's the line in my .vbs file that is getting the error:

> > set o1 = Wscript.CreateObject("Test1.Obj1.1", "TestObj1_")

> AH.
> So i think you sould use it like this:

> set objadr = Wscript.CreateObject("Test1.Obj1")

> if you did an project like you wrote then you have to build the objadr
> without the location
> i think the location is only for DCOM apps you can creat objects over
> the network.

> Alternativly you could use it with the version number but this is
> normally only needed when
> you more than one version and to acces an old version you must creat it
> like this.
> set objadr = Wscript.CreateObject("Test1.Obj1.1")

> And you can even write:
> set objadr = CreateObject("Test1.Obj1.1")
> because in script unknown function calls are searched in the host of
> wsricpt.

> Robert



Mon, 07 Apr 2003 03:00:00 GMT  
 WScript.CreateObject: Requirements for object?

See my response to the new thread you started...

--
Michael Harris
Microsoft.MVP.Scripting
--

Quote:
> > Set to1 = WScript.CreateObject("Test.Obj1","foo_")

> > and (I think) you'll get the "...could not connect..." error because the
> object doesn't expose any
> > events

> The object has to expose events?  Is this documented somewhere?
> Regardless, that is the correct answer.  When I rebuilt my object so
> it had connection points (I think that's right) and added an event, then
> it worked.

> Thanks again for your help, Michael Harris.



> > Chad,

> > Sam is using WScript.CreateObject...

> > Try:

> > '------------------
> > Dim to1
> > Dim s1

> > Set to1 = WScript.CreateObject("Test.Obj1")

> > s1 = "yadda, yadda"

> > to1.DoHelloWorld s1

> > MsgBox s1
> > '------------------

> > It _should_ work just the same, assuming this is the syntax Sam is using.

> > Now try:

> > Set to1 = WScript.CreateObject("Test.Obj1","foo_")

> > and (I think) you'll get the "...could not connect..." error because the
> object doesn't expose any
> > events.

> > --
> > Michael Harris
> > Microsoft.MVP.Scripting
> > --




> > > > I am pretty sure I have the right prog id.  I tried
> > > > both "test.obj1.1" and "test.obj1", names that were
> > > > in my registration.

> > > > I built the project with the ATL wizard.  Last night
> > > > I built a new object using the ATL wizard.  I built
> > > > the most vanilla object possible.  Nothing added.
> > > > Just whatever is built by the wizard.

> > > > I get the same error with this object as with my
> > > > simple test case.

> > > Hmm... I don't know what to tell you then. I do the
> > > exact same thing, and it works.

> > > Open C++

> > > New Project

> > > ATL AppWizard, project name "Test"

> > > DLL, no special options (no MFC, etc)

> > > Right-click on "Test Classes" project classes,
> > > New ATL Object, Simple Object, class name: obj1

> > > Add new Method:
> > >   DoHelloWorld
> > > Parameters:
> > >   VARIANT *vStr

> > > STDMETHODIMP Cobj1::DoHelloWorld(VARIANT *vStr)
> > > {
> > >  VariantInit(vStr);
> > >  CComBSTR bstr("Hello, World!");
> > >  V_VT(vStr) = VT_BSTR;
> > >  vStr->bstrVal = bstr.Copy();

> > >  return S_OK;
> > > }

> > > Compile, rinse, repeat.

> > > Now, the vbs code:

> > > '------------------
> > > Dim to1
> > > Dim s1

> > > Set to1 = CreateObject("Test.Obj1")

> > > s1 = "yadda, yadda"

> > > to1.DoHelloWorld s1

> > > MsgBox s1
> > > '------------------

> > > (message box pops up with "Hello, World!")

> > > -Chad



Mon, 07 Apr 2003 03:00:00 GMT  
 WScript.CreateObject: Requirements for object?
If your component doesn't expose events, then simply use

set o1 = Wscript.CreateObject("Test1.Obj1.1")
or
set o1 = CreateObject("Test1.Obj1.1")

as I implied and Robert clearly stated...

You only use the 2nd argument for objects that expose events AND you want to handle them...

--
Michael Harris
Microsoft.MVP.Scripting
--

Quote:
> Michael Harris suggested that it wasn't working because
> my object did not have any events.  He was correct.
> I rebuilt the object to expose events and it worked fine.
> So the problem is solved thanks to Mr. Harris.

> I tried both the names below, "Test1.Obj1.1" and just
> "Test1.Obj1".  Both worked.  I am pretty sure the intent
> here is you use "Test1.Obj1" and as you create new versions
> of the object, e.g., Test1.Obj1.1, Test1.Obj1.2, ..., you'll
> always get the latest version.



> > >    ProgID = s 'Test1.Obj1.1'
> > >    VersionIndependentProgID = s 'Test1.Obj1

> > > Here's the line in my .vbs file that is getting the error:

> > > set o1 = Wscript.CreateObject("Test1.Obj1.1", "TestObj1_")

> > AH.
> > So i think you sould use it like this:

> > set objadr = Wscript.CreateObject("Test1.Obj1")

> > if you did an project like you wrote then you have to build the objadr
> > without the location
> > i think the location is only for DCOM apps you can creat objects over
> > the network.

> > Alternativly you could use it with the version number but this is
> > normally only needed when
> > you more than one version and to acces an old version you must creat it
> > like this.
> > set objadr = Wscript.CreateObject("Test1.Obj1.1")

> > And you can even write:
> > set objadr = CreateObject("Test1.Obj1.1")
> > because in script unknown function calls are searched in the host of
> > wsricpt.

> > Robert



Mon, 07 Apr 2003 03:00:00 GMT  
 
 [ 12 post ] 

 Relevant Pages 

1. WScript.CreateObject: requirements of object?

2. Could not connect object. WScript.CreateObject -2147352567

3. Diff between WScript.CreateObject & CreateObject

4. WScript.CreateObject vs CreateObject

5. Set WSHShell = WScript.CreateObject("WScript.Shell")

6. Creating events with WScript.CreateObject

7. WScript.CreateObject question

8. WScript.CreateObject

9. Wscript CreateObject Fails!

10. can't CreateObject("Wscript.Shell")

11. Creating events with WScript.CreateObject

12. I need more infos about WScript.CreateObject()

 

 
Powered by phpBB® Forum Software