在 Kinect SDK 中加载 INuiInstanceHelper 时出现不一致问题

发布于 2024-11-19 15:47:57 字数 1732 浏览 0 评论 0原文

我在这里和 MSDN 论坛上都发现了这个问题以及该问题的潜在解决方案,但我的问题有点不同。当我在 Runtime 类上调用 ctor 时,出现以下异常:

System.IO.FileNotFoundException:无法加载文件或程序集“INuiInstanceHelper,Version=1.0.0.10,Culture=neutral,PublicKeyToken=31bf3856ad364e35”或其依赖项之一。

在简单场景中构造运行时(例如 WPF 中的 Loaded 事件。请参阅下面的简单场景代码)时,我没有收到此错误。

在我的真实场景中,当用户从打开的文件对话框中打开文件时,将调用我的运行时构造函数。这是从 ViewModel 中的 MenuItem 命令开始的,该命令使用包装打开文件对话框的“服务”。然后,ViewModel 在指定文件路径后初始化运行时:

void ExecuteOpenCommand()
{
    var path = this.openFileService.OpenFile();

    if (!string.IsNullOrEmpty(path))
    {
        var model = ViewModelLoader.ReadMainModel(path);
        var viewModel = ViewModelLoader.LoadViewModel(model);
        this.MainViewModel = viewModel;
        this.MainViewModel.NuiService = this.nuiService;
        this.nuiService.Initialize();
    }
}

如果之前从未初始化过,则 nuiService 仅构造运行时:

bool initialized;
public void Initialize()
{
    if (initialized)
    {
        return;
    }

    try
    {
        this.runtime = new Runtime();
    }
    catch (FileNotFoundException ex)
    {
        Trace.WriteLine(ex.ToString());
    }

    // ...
    initialized = true;
}

但是,当我启动 WPF 项目时从头开始构建运行时,我没有收到此错误:

// does not throw exception
void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
    Runtime r = new Runtime();
    r.Initialize(RuntimeOptions.UseSkeletalTracking);
    r.Uninitialize();
}

当 Google 搜索此异常时,我遇到了需要更新 DirectX、重新启动、更新 Windows 或将 INuiInstanceHelper 重新安装到 GAC 的解决方案。我不知道这些解决方案有什么帮助,因为我可以以不同的方式构建没有错误的运行时。我认为我的问题一定与用户启动(例如通过按钮单击)有关,但是当我将运行时构造函数移动到在应用程序启动附近执行的方法时(例如在实例化的 ViewModel 的构造函数中)通过数据绑定声明)我仍然有问题。想法?

I've found this issue and potential resolutions to this issue both here and on the MSDN forums but my problem is a little different. When I call the ctor on the Runtime class, I get this exception:

System.IO.FileNotFoundException: Could not load file or assembly 'INuiInstanceHelper, Version=1.0.0.10, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.

I do not get this error when constructing the Runtime in a simple scenario (e.g. a Loaded event in WPF. see my simple scenario code below).

In my real scenario, my Runtime's ctor is called when a user opens a file from an open file dialog. This is kicked off from a MenuItem command in a ViewModel, which uses a "service" that wraps the open file dialog. The ViewModel then initializes the Runtime after the file path is specified:

void ExecuteOpenCommand()
{
    var path = this.openFileService.OpenFile();

    if (!string.IsNullOrEmpty(path))
    {
        var model = ViewModelLoader.ReadMainModel(path);
        var viewModel = ViewModelLoader.LoadViewModel(model);
        this.MainViewModel = viewModel;
        this.MainViewModel.NuiService = this.nuiService;
        this.nuiService.Initialize();
    }
}

The nuiService just constructs the Runtime if it has never been initialized before:

bool initialized;
public void Initialize()
{
    if (initialized)
    {
        return;
    }

    try
    {
        this.runtime = new Runtime();
    }
    catch (FileNotFoundException ex)
    {
        Trace.WriteLine(ex.ToString());
    }

    // ...
    initialized = true;
}

However, when I start a new WPF project from scratch and construct the runtime, I do not get this error:

// does not throw exception
void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
    Runtime r = new Runtime();
    r.Initialize(RuntimeOptions.UseSkeletalTracking);
    r.Uninitialize();
}

When Googling this exception I've come across solutions that require updating DirectX, rebooting, updating Windows, or reinstalling INuiInstanceHelper to the GAC. I don't see how these solutions will help since I can construct the Runtime without error in a different way. I thought my problem must have something to do with it being user-initiated (e.g. from a Button Click), but when I moved the Runtime constructor to a method that gets executed near app startup (e.g. in the ctor of my ViewModel which is instantiated declaratively through data-binding) I still had the issue. Thoughts?

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

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

发布评论

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

评论(1

幻梦 2024-11-26 15:47:57

答案是将 Platform Target 更改为 x86。由于某种原因,它被设置为“任何 CPU”。咕噜……

The answer was to change the Platform Target to x86. For some reason it got set to Any CPU. grrrr....

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