使用 FluorineFx 和 .Net 时的弹性"Unable to cast object of type 'FluorineFx.ASObject' to type."



使用 Flex 调用 .Net 方法时,远程调用时出现转换错误。错误说:

无法将类型为"FluorineFx.ASObject"的对象转换为类型 com.mynamespace.MyAccessControlType

调用方是 flex,服务在 .net 中提供。它使用FlourineFx进行沟通/桥接双方。

弹性调用类似于:

public class SavePageDelegate
    {
        private var responder:IResponder;
        private var service:RemoteObject;
        public function SavePageDelegate(page:PageType, responder:IResponder):void
        {
            this.service = ServiceLocator.getInstance().SavePage(page);
            this.responder = responder;
        }
    }

远程方法如下。请注意,页面对象的发送没有问题。页面对象具有权限 (MyAccessControlType( 的 ArrayList (AccessControlList(。当我尝试使用 foreach 访问元素时,会抛出错误:

    /* this is called from Flex*/ 
    public string SavePage(PageType page){
        ...
        InsertAccessControl(page.AccessControlList);
    }
    /* This is called from SavePage */
    public void InsertAccesControl(System.Collections.ArrayList AccessControlList);
    {
        // This is the line where the error is triggered
        foreach (com.mynamespace.MyAccessControlType item in AccessControlList)
        {
            ...
        }
    }

我使用这些页面作为参考:http://www.fluorinefx.com/docs/fluorine/typeconversion.html - 显示对氟/柔性对象有效的类型转换

http://www.fluorinefx.com/docs/fluorine/classmapping.html - 用于类映射。

您的 flex 声明中似乎缺少 MyAccessControlType 的映射,因为它被视为通用 AsObject。

映射将是这样的:

[RemoteClass(alias="com.mynamespace.MyAccessControlType")]

这应该允许您查看完整的远程类,从而消除转换问题。希望这对:D有所帮助

相关内容

最新更新