Uploaded image for project: 'Apache Flex'
  1. Apache Flex
  2. FLEX-18885

When calling from C# to Flash using Flex CallFunction(), it fails with E_Fail exception

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • Adobe Flex SDK 3.0 (Release)
    • None
    • Flash Integration
    • None
    • Affected OS(s): Windows
      Affected OS(s): Windows XP
      Browser: Internet Explorer 7.x
      Language Found: English

    Description

      Steps to reproduce:
      We have an Add-in to Excel, built using Microsoft's Visual Studio Toolkit for Office (VSTO). We're trying to use a Flash component to drive a C# library and we're having trouble communicating with the Flash component. The same code works outside of the plugin (in an application, for example) but fails within Excel. We're developing on 32-bit Windows XP systems using Visual Studio 2008.

      We observe two problems:
      1. When using the Flash CallFunction() to make a call from C# to Flash, an E_Fail exception is thrown.
      2. When using ExternalInterface.call() to make a call from Flash to C#, no exception is thrown, but the handler method is not invoked or nothing happens. This problem happens when the latest Flash version(Flash10b.ocx) is installed. It does not happen if installing Flash 10 debug version (FlDbg10b.ocx)

      We've included a simple project and Flash component that demonstrates the problem. To reproduce the problem, you will need:

      • The latest flash player (Flash 10)
      • Visual Studio 2005/2008 to launch our simple application that embeds Flash.

      There are three zip files:
      1. SimpleSwiff.zip: contains a SWF file
      2. SimpleSwiff_SrcCode.zip: contains the source code for SimpleSwiff.swf
      3. Excel_Flash.zip: contains the simple Excel plugin project that implements both Flash to C# and C# to Flash functions.

      How to launch our demo:

      • Extract the SWF file from SimpleSwiff.zip to the C:\ directory so that you have c:\SimpleSwiff.swf.
      • Extract the Excel_Flash.zip and WindowsForms_Flash.zip files anywhere on your machine, launch them in a supported application (e.g. Visual Studio 2005/2008) and build the projects.

      To Show the Flash Component Working in the ActiveX Test Container (available in the Visual Studio C++ samples from Microsoft http://www.microsoft.com/downloads/details.aspx?FamilyId=01AE159F-08CD-495B-8BF4-A48CC395AD7B&displaylang=en; look for the C++\MFC\ole\TstCon folder)
      1. Start ActiveX control test container
      2. Edit->Insert new Control
      3. Select Shockwave Flash Object and click ok
      4. Select Control->Invoke Methods from ActiveX Test Container menu
      5. Select method name "Movie (PropPut)"
      6. Enter the parameter value below:
      c:/SimpleSwiff.swf
      7. Click the "Set Value" button.
      8. Click "Invoke" button; the control will change color and a message will appear : "Initial number = 0"
      9. Back in Invoke Methods dialog, change Method Name to "CallFunction(Method)"
      10. Enter the below for Parameter Value:
      <invoke name="increment" returntype="xml" />
      11. Click set Value button then click "Invoke" button; message changes to "After increment, number = 1."

      To Show the Flash Component Failing in Excel:
      1. Extract Excel_Flash.zip file
      2. Launch the FlashInPaneExcel.sln file in Visual Studio and run the project
      3. Excel starts up with movie loaded (note if you copied the swf file somewhere else you will need to change it in the code, since the code expects to load c:\SimpleSwiff.swf).
      4. Click the increment button.
      5. Exception is thrown with E_FAIL as hr.
      6. Click the button "Increment call from Flash", nothing happens.

      Note: if you receive a security sanbox violation message, have to resolve this error first by setting Flash global security setting to have access to the SimpleSwiff.swf file before continuing.

      To see the souce code of SimpleSwiff:

      • Extract the SimpleSwiff_SrcCode.zip
      • Open it in Flex Builder Version 3 or any application that can open a Flex project.

      The SimpleSwiff contains the following main file:

      • SimpleSwiff.mxml - Flex application file which does all the tasks needed from Flash side. It includes the following:
      • The method init() which registers the methods (e.g. increment() and clear() methods) which c# side will call.
        The way we register:
        flash.external.ExternalInterface.addCallback("increment", increment);
        flash.external.ExternalInterface.addCallback("clear", clear);
      • The implementation of the 2 methods above. The increment method increase the number variable by 1. The clear() method reset it to 0. From C# side, when we call these 2 methods using AxShockwaveFlash.CallFunction(string request), the methods from mxml file will be invoked.
      • A button that after clicking, it invokes the the method incrementFromFlash() which implements the call from Flash to C#.

      Other testing:
      We've also built an Add-in for Word and Powerpoint (not included) that fails, so it's not simply something with Excel.

      Why does the Flash player fail within these Office applications? Is there a workaround, and are there plans to address the problem?

      We are using the following versions (however, the exact versions of the software don't seem to be a factor in this problem)

      Microsoft Windows XP Professional Version 5.1.2600 Service Pack 2 Build 2600
      Microsoft Office Excel 2007 (12.0.6214.1000) SP1 MSO (12.0.6213.1000)
      Flex Builder Version 3

      Actual Results:
      Got an E_Fail error.

      Expected Results:
      Should work the same as in ActiveX Control Test container as mentioned above.

      Workaround (if any):
      None

      Attachments

        Activity

          People

            Unassigned Unassigned
            adobejira Adobe JIRA
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: