I have this problem too and I think I found why this error ocurs, but I still do not know ho to reslove it.
Not only C# projects have such bug, C++ and Assembler code also failed with it.
My task for now is to write plugin for some program. This plugin provides user interface for some internal beings of program. User interface done using Flash movie(Flex 2) played usnig ActiveX Flash control. To comunicate between plugin and movie I use CallFunction method of IShockwaveFlash interface.
On the first steps I wrote simple application which emualtes behavior of program. All works perfectly. But when I ported communcation code into a DLL CallFunction begun to return E_FAIL value.
I think the reason is that ActiveX Control checks in which module it was created. If it was created in startup module(someprogam.exe) it works perfectly. But when it was created in DLL module(various plugins etc) it disables some features(I think for security reason). One of those features is method callFunction. I lost 3 month trying reslove this problem.
I've seen others reporting this problem, but seen no resolution so far. It may be that this problem occurs only on some machines? For example, the sample .NET program here http://www.codeproject.com/cs/media/flashexternalapi.asp?df=100&forumid=226349&exp=0&selec t=1518421 doesn't work on my machine, although it should have worked on the author's machine.
I tried 5 different machine with different configurations but that don't reslove problem.
I guess you are right. I've got another suspicion that this bug may be due to some multi-threading issues but it's hard to tell.
I wonder if Adobe can hear us and fix this bug in the following version of Flash Player. Through the previous versions, this bug survived over and over again :(
Currently, I've created the following workaround: in Flash movie, I set a timer which sends (e.g. 10 times a second) the hosting program a request for a command(s) to execute. In this way the direct call (CallFunction) is no longer needed and replaced with callback (ExternalInterface.call). I know it's an ugly solution, but it works and I don't observe any tangible performance issues. Hope this can be helpful to others.
Workaround, you offered, is widely used among other programmers, but it looks like sadism. I offer you to try another way, but you must be a litle familiar with writing COM servers(I have no other choice;-( ). I'll try it soon and advice you to try it. I offer to write own AxtiveX Control whitch will create Flash control. The thing is that the server which serves control must be LocalServer i.e. exe program, in order to use all feature of Flash Control instance createt by it(including CallFunction which calls now must be successfully completed). This is very simple to Aggregation(in COM terminology), and hope it will be working.
PS: I understand my workaround also looks like sadism, but "What can I do?"
Would you please have a code snippet on the workaround?
I couldn't get it worked so I guess I may understand it wrong.
Just figured this one out. I'm using VC++ 6 with ActiveX Flash 10. The code snippets here will call the Flash function testFunction from VC++ using the CallFunction command and the appropriate XML. In VC++, make the following call assuming that m_flashGUI is the CShockwaveFlash object added to your dialog.
CString ret = m_flashGUI.CallFunction("<invoke name=\"testFunction\" returntype=\"xml\">"
The key item in the xml string is the "name" parameter. It must match the name in the addCallback function in the Flash movie.
In the flash movie, have something like the following. The addCallback call is important. Without it the CallFunction from C++ will throw an exception.
// Import the flash items
// Associate the flash function with the external call
// Do something here...
Thanks for your response.
That was what I did in C#, but it didn't work when our application is launched inside Excel, outside Excel, everything works.