ActiveX - Unexpected call to method or property access

V

Vinay S

Hi,

I have a ActiveX control. I have a couple of methods exposed.

When I try to invoke these methods using Javascript, I get an Error
Message : "Unexpected call to method or property access"

This works fine if I embed the ActiveX as an object.5

My code is as below:

<!-- This code works -->
<OBJECT CLASSID="CLSID:BEF77186-6Q43-4E21-B1F1-52AF55F55559"
ID="MyActiveX1" ></OBJECT>
<script>
if (MyActiveX1 != null)
MyActiveX1.isLoaded() ;
</script>

<!-- This code fails -->
<script>
var MyActiveX1 = new ActiveXObject("MyLib.MyObj.1") ;
if (MyActiveX1 != null)
MyActiveX1.isLoaded() ; // <-- this is where it fails...
</script>

Please let me know where I am going wrong.

Any hints would be useful.

Thanks and regards,
Vinay
 
T

Thomas 'PointedEars' Lahn

Vinay said:
I have a ActiveX control. I have a couple of methods exposed.

When I try to invoke these methods using Javascript,

Most certainly you are using Microsoft _JScript_.
I get an Error Message : "Unexpected call to method or property access"

This works fine if I embed the ActiveX as an object.5

Maybe it was designed that way.
My code is as below:

<!-- This code works -->
<OBJECT CLASSID="CLSID:BEF77186-6Q43-4E21-B1F1-52AF55F55559"
ID="MyActiveX1" ></OBJECT>
<script>

if (MyActiveX1 != null)
MyActiveX1.isLoaded() ;

Do you realize that this code will *break* (throwing a ReferenceError
exception) if there is no element with ID `MyActiveX1' or the layout engine
is not MSHTML-compliant? Use the following instead:

var myActiveX1 = document.getElementById("MyActiveX1");
if (myActiveX1)
{
myActiveX1.isLoaded();
}

Add feature tests as needed. You may also add a branch using `document.all'
if you want to support IE/MSHTML 4.
</script>

<!-- This code fails -->
<script>

See above.
var MyActiveX1 = new ActiveXObject("MyLib.MyObj.1") ;
if (MyActiveX1 != null)

This does not make sense to me. Either constructing the object should throw
an exception before reaching this line or `MyActiveX1' should store an
object reference.
MyActiveX1.isLoaded() ; // <-- this is where it fails...

Maybe an object different than you think was constructed.
</script>

Please let me know where I am going wrong.

Any hints would be useful.

Please read
<http://msdn.microsoft.com/en-us/library/7sw4ddf8(VS.85).aspx> and check
your assumptions. Is "MyLib.MyObj.1" really the PROGID of your ActiveX/COM
object? Maybe you should ask in a group having "activex" in its name, and
report your findings here.

<http://jibbering.com/faq/#posting>


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top