StaticPropertyWatcher.as 抛出异常

发布于 2024-12-06 05:04:38 字数 1471 浏览 1 评论 0原文

最近,我突然开始收到 Flex 库抛出的当前异常。我正在处理的文件(Login.mxml)在加载时突然开始抛出此异常。

TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at mx.binding::StaticPropertyWatcher/updateParent()[E:\dev\4.x\frameworks\projects\framework\src\mx\binding\StaticPropertyWatcher.as:150]
    at _components_LoginWatcherSetupUtil/setup()
    at components::Login()[C:\Users\username\Documents\MP_MAIN\src\components\Login.mxml:0]
    <snip ...>
    at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:700]
    at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:1072]

在调试器中运行它不会给我带来一行错误的代码,但它确实给我带来了 StaticPropertyWatcher 中的一行。具体来说:

override public function updateParent(parent:Object):void
{
    // The assumption is that parent is of type, Class, and that
    // the class has a static variable or property,
    // staticEventDispatcher, of type IEventDispatcher.
    parentObj = Class(parent);

    if (parentObj["staticEventDispatcher"] != null) /* Exception thrown from here */
    {
    ...

调试器显示 parentObj 确实为 null,解释了异常的直接原因,但我似乎无法确定更深层次的原因(即我做错了什么)。 updateParent 方法是从 _components_LoginWatcherSetupUtil 类中调用的,但调试器表示没有相应的代码,因此我编写的内容与导致异常的原因之间的关键联系丢失了。

所以,基本上,我什至无法调试它。您有什么想法可以弄清楚到底出了什么问题吗?

Recently, I suddenly began getting the current exception being thrown from a Flex library. The file I was working on (Login.mxml) suddenly began throwing up this exception while loading.

TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at mx.binding::StaticPropertyWatcher/updateParent()[E:\dev\4.x\frameworks\projects\framework\src\mx\binding\StaticPropertyWatcher.as:150]
    at _components_LoginWatcherSetupUtil/setup()
    at components::Login()[C:\Users\username\Documents\MP_MAIN\src\components\Login.mxml:0]
    <snip ...>
    at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:700]
    at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:1072]

Running it in the debugger doesn't give me a line of my code that is in error, but it does give me a line in StaticPropertyWatcher. Specifically:

override public function updateParent(parent:Object):void
{
    // The assumption is that parent is of type, Class, and that
    // the class has a static variable or property,
    // staticEventDispatcher, of type IEventDispatcher.
    parentObj = Class(parent);

    if (parentObj["staticEventDispatcher"] != null) /* Exception thrown from here */
    {
    ...

The debugger shows the parentObj is indeed null, explaining the immediate reason for the exception, but I can't seem to determine the deeper cause (i.e. what I did wrong). The updateParent method is being called from the _components_LoginWatcherSetupUtil class, but the debugger says there is no code for that, so the crucial connection between what I wrote and what caused the exception is missing.

So, basically, I can't even debug this. Any ideas for what to do to shed light on what's going wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

独自←快乐 2024-12-13 05:04:38

您的错误被报告为 Login.mxml:0
当我看到第 0 行错误时,它告诉我存在某种语法错误。也许是开弦?

我建议查看该文件并查看其设置是否正确。

发布完整的 Login.mxml 文件,让我们看一下。

Your error is being reported as Login.mxml:0
When I see line 0 as the error it tells me that there is a syntax error of some sort. Open string maybe?

I would suggest looking at the file and see if it is set up properly.

Post the full Login.mxml file and let us look at it.

眼泪都笑了 2024-12-13 05:04:38

在费力地添加自上次提交到存储库以来所做的所有更改后,我找到了这个问题的罪魁祸首。基本上,有几个静态变量用于跟踪服务器地址,如下所示:

public static var MAIN:String = "http://192.168.1.1/";
public static var MANAGE:String = MAIN + "Manage/";

问题是我使用非编译时常量 MAIN 来初始化 MANAGE。将这些变量更改为 const 解决了问题。

public static const MAIN:String = "http://192.168.1.1/";
public static const MANAGE:String = MAIN + "Manage/";

希望这能帮助其他遇到这个问题的人

After laboriously adding back every change I made since last committing to my repository, I tracked down the culprit to this problem. Basically, there were several static variables used to keep track of server addresses like this:

public static var MAIN:String = "http://192.168.1.1/";
public static var MANAGE:String = MAIN + "Manage/";

The issue was that I used a non-compile-time constant MAIN to initialize MANAGE. Changing these variables to const fixed the problem.

public static const MAIN:String = "http://192.168.1.1/";
public static const MANAGE:String = MAIN + "Manage/";

Hopefully this will help anyone else coming across this problem

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文