使用 System.Diagnostics.Process.Start 运行程序会导致 MissingMethodException

发布于 2024-09-14 21:07:04 字数 1002 浏览 2 评论 0原文

我正在开发一个 Compact Framework 2.0 项目,并尝试使用 Process.Start 从另一个程序“A”中启动程序“B”。我之前已经这样做过好几次了,但是这次我遇到了一些奇怪的问题。

程序“B”确实启动了,但它导致了 MissingMethodException,基本上告诉我它缺少它引用的某个程序集。问题是程序集 .dll 就在那里,与程序“B”位于同一文件夹中。如果我双击程序“B”,它会正确运行,没有 MissingMethodException,只有在程序“A”中使用 Process.Start 启动时才会出现此问题。我完全不知道这里发生了什么。我尝试设置工作目录属性,但没有成功。关于为什么程序在通过 Process.Start 执行时无法加载其引用的任何想法?谢谢

System.Diagnostics.Process proc = new System.Diagnostics.Process();
            ProcessStartInfo startInfo = new ProcessStartInfo(programBFullPath, "argument");

            //I've been changing these two properties, have tried shell execute with both false and true, tried setting working directory and not setting it also
            startInfo.UseShellExecute = false;
            startInfo.WorkingDirectory = programBDirectory;

            proc.StartInfo = startInfo;
            proc.Start();

编辑我只是想到了一件事...程序“A”和程序“B”都使用了程序“B”未加载的.dll。如果两个程序无法同时加载相同的 .dll,那么这就是问题所在。是这样吗?

I'm working on a Compact Framework 2.0 project, and I'm trying to launch a program "B" from within another program "A" using Process.Start. I've done this several times before, but I'm running into some weird issues this time.

Program "B" does launch, but it causes a MissingMethodException, basically telling me that it is missing a certain assembly that it has referenced. The problem is that the assembly .dll is right there, in the same folder as program "B". If I double-click on program "B", it runs correctly with no MissingMethodException, it is only when launched with Process.Start in program "A" that this problem occurs. I've absolutely no clue what is going on here. I tried setting the WorkingDirectory property with no luck. Any ideas as to why the program can't load its references when executed through Process.Start? Thanks

System.Diagnostics.Process proc = new System.Diagnostics.Process();
            ProcessStartInfo startInfo = new ProcessStartInfo(programBFullPath, "argument");

            //I've been changing these two properties, have tried shell execute with both false and true, tried setting working directory and not setting it also
            startInfo.UseShellExecute = false;
            startInfo.WorkingDirectory = programBDirectory;

            proc.StartInfo = startInfo;
            proc.Start();

EDIT I just thought of something... Both program "A" and program "B" use the .dll that program "B" is not loading. If two programs can't load the same .dll at the same time then that is the issue. Is this the case?

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

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

发布评论

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

评论(2

小嗷兮 2024-09-21 21:07:04

设备上的内存压力如何?如果程序 B 依赖于程序集 C,但没有足够的内存(虚拟或物理)来加载程序集 C,那么您将得到 MissingMethodException(而不是 OutOfMemoryException,我一直认为后者更有意义)。

How does memory pressure look on the device? If Program B relies on Assembly C, but there is insufficient memory (virtual or physical) to load assembly C, then you'll get a MissingMethodException (instead of an OutOfMemoryException, which I always thought would make more sense).

梦中的蝴蝶 2024-09-21 21:07:04

我通过复制程序 B 的程序集上的引用代码并删除所有引用来使其工作。它远非优雅,但我无法让它以任何其他方式工作。如果有人知道可能出了什么问题,我将不胜感激。其他时候它可能会派上用场。谢谢

Well I made it work by duplicating the referenced code on program B's assembly and removing all references. It is far from elegant, but I couldn't get it to work any other way. If anyone has any idea of what might have gone wrong I would greatly appreciate it. It might come in handy some other time. Thanks

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