0

I've built a small activex control using c#. I've got a function that returns an array of bytes. From some reason when I try to consue the returned array in js I receive an undefined value. Why is this happenning? Is there anyway to solve it?

Here's a simple demonstration of my code:

Activex:

[ComVisible(true)]
        public byte[] Close()
        {
            try
            {
                MessageBox.Show("called from activex Close");
                return Stop();
            }
            catch (Exception e)
            {
                //ExceptionHandling.AppException(e);
                throw e;
            }
        }

Javascript Call:

function CloseActiveX(){
var myRslt = document.OurActiveX.Close();
}
1
  • Could you add the code that is not working? Commented Aug 3, 2009 at 20:11

1 Answer 1

1

You haven't shown what the Stop() method contains. If Stop() returns null, you should expect to see what you're seeing.

As it stands, however, it looks like your ActiveX control is written in .NET. This is a bad idea for myriad reasons, not the least of which that performance will be low, and you will encounter problems if there are other controls or extensions running in the browser that want a different version of the framework.

Beyond that problem, the likely issue is that the byte[] isn't being marshalled back to the caller in a way that allows its use. You need to return a VARIANT with the following properties: ARRAY, BYREF, U1.

Default Marshaling for Arrays may be useful.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.