Question

I am attempting to make an AIR Native Extension and after successful compilation of all components, Flash Builder 4.6 logs "Error #3500: The extension context does not have a method with the name...".

Here's the C++ code for the native DLL:

#include "stdafx.h"
#include "TestANE.h"

#include "FlashRuntimeExtensions.h"

#include <string>
#include <iostream>
#include <iomanip>
#include <algorithm>

using namespace std;

FREObject isSupported(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) {
    FREObject result;

    uint32_t isSupportedSwitch = 1;
    FRENewObjectFromBool(isSupportedSwitch, &result);

    return result;
}

FREObject getString(FREContext ctx, void* funcData, uint32_t argc, FREObject argv[]) {
    FREObject result;

    const char *testString = "Hello World from C++!";
    FRENewObjectFromUTF8(strlen(testString)+1, (const uint8_t *) testString, &result);

    return result;
}

void taneContextInitializer(void* extData, const uint8_t* ctxType, FREContext ctx, uint32_t* numFunctions, const FRENamedFunction** functions) { 
    *numFunctions = 2;
    FRENamedFunction* func = (FRENamedFunction*) malloc(sizeof(FRENamedFunction) * (*numFunctions));

    func[0].name = (const uint8_t*) "isSupported";
    func[0].functionData = NULL;
    func[0].function = &isSupported;

    func[1].name = (const uint8_t*) "getString";
    func[1].functionData = NULL;
    func[1].function = &getString;

    *functions = func;
}

void taneContextFinalizer(FREContext ctx) {
    return;
}

void taneInitializer(void** extData, FREContextInitializer* ctxInitializer, FREContextFinalizer* ctxFinalizer) { 
    *ctxInitializer = &taneContextInitializer;
    *ctxFinalizer = &taneContextFinalizer;
}

void taneFinalizer(void* extData) {
    return;
}

Here's the code for the ActionScript 3 interface:

package com.tests.TestANE {
    import flash.events.EventDispatcher;
    import flash.events.IEventDispatcher;
    import flash.external.ExtensionContext;

    public class TestANE extends EventDispatcher {

        private var _ExtensionContext:ExtensionContext;

        public function TestANE(target:IEventDispatcher=null) {

            this._ExtensionContext = ExtensionContext.createExtensionContext("com.tests.TestANE", null);

            super(target);
        }

        public function isSupported():Boolean {
            return _ExtensionContext.call("isSupported") as Boolean;
        }

        public function getString():String {
            return _ExtensionContext.call("getString") as String;
        }

        public function dispose():void {
            this._ExtensionContext.dispose();
        }
    }
}

Any help in solving this issue would be appreciated.

Was it helpful?

Solution 5

I've solved this problem. I am not completely certain how as I started with another ANE project and built from there. I suspect however that the problem had to do with wrong package names in the ActionScript part of the code and the extension descriptor.

OTHER TIPS

Please see before here: http://forums.adobe.com/thread/923158

If you got this error when you have more than one extension inside the same project, please be careful: EVERY initializer end finalizer methods MUST have different and unique names between ALL the extensions. NB. Not only the methods specified in extension.xml but also the ones you delagate to initialize the context. To be clear: NOT only the extension initializer but also the context initializer inside the project MUST have unique names between ALL the extensions.

Eg.:

 void UNIQUE_NAME_ExtInitializer(void** extDataToSet, FREContextInitializer* ctxInitializerToSet, 
                    FREContextFinalizer* ctxFinalizerToSet) {

       NSLog(@"Entering ExtInitializer()");

       *extDataToSet = NULL;
       *ctxInitializerToSet = &UNIQUE_NAME_ContextInitializer;
       *ctxFinalizerToSet = &UNIQUE_NAME_ContextFinalizer;

       NSLog(@"Exiting ExtInitializer()");
}

void UNIQUE_NAME_ContextInitializer(void* extData, const uint8_t* ctxType, FREContext ctx, 
                        uint32_t* numFunctionsToTest, const FRENamedFunction** functionsToSet) 
{

    *numFunctionsToTest = 1;

    FRENamedFunction* func = (FRENamedFunction*) malloc(sizeof(FRENamedFunction) * 1);
    func[0].name = (const uint8_t*) "scan";
    func[0].functionData = NULL;
    func[0].function = &scan;

    *functionsToSet = func;
}

And the same for the finalizer.

I hope this helps.

To resolve symbol name conflicts between ANEs, there is a new ADT option in AIR 3.4 i.e. hideANELibSymbols

Refer: http://help.adobe.com/en_US/air/build/WS901d38e593cd1bac1e63e3d128cdca935b-8000.html

Also, to ease the process of getting started with writing an ANE for iOS, I've written an xcode ANE template.

Refer: https://github.com/divijkumar/xcode-template-ane

Do read the instructions on the github wiki page before getting started.

Had the same issue but on concrete machine (others work just fine) and nothing help until i rebuild my dll with release flag. It seems like debug version request some addination dll's installed on user pc, so make sure you build with release flag!

It appears that the C++ function "getString" has required arguments. So when you are calling _ExtensionContext.call("getString") as String; C++ does not have a getString() method. It wants you to pass through arguments also. Add these to teh call method like so:

_ExtensionContext.call("getString", arg, arg1, arg2) as String;

The arguments you pass must be of the appropriate type specified by the c++ getString method.

See the reference: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/external/ExtensionContext.html#call()

This question is old, but there is no solid answer. I ran into the same issue with an Android ANE. In your FREExtension function/class, you must return a new instance of FREContext and in that instance of FREContext, you must return the function map. I made the mistake of not returning the map and running around like a chicken with its head cut off trying to figure out what was going on. Hopefully that will help someone in the future.

I had this same issue and none of the other answers here solved it for me. I was trying to create a simple c++ ANE for the Blackberry Playbook and would get an error #3500 any time I tried to run it. The same exact code worked fine in C. It turns out the c++ compiler was doing method name mangling so it could not find the method I was calling. I solved it by wrapping my function definitions in extern "C" like this:

extern "C" {
    void ExtensionInitializer(void** extDataToSet,
        FREContextInitializer* ctxInitializerToSet,
        FREContextFinalizer* ctxFinalizerToSet);
    void ExtensionFinalizer();

    void ContextInitializer(void* extData, const uint8_t* ctxType, FREContext ctx,
        uint32_t* numFunctionsToSet, const FRENamedFunction** functionsToSet);
    void ContextFinalizer(FREContext ctx);

    FREObject myMethod(FREContext ctx, void* functionData, uint32_t argc,
        FREObject argv[]);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top