.NET 程序集未从 NTVDM 加载

发布于 2024-07-13 16:54:55 字数 1898 浏览 4 评论 0原文

我有一个 VDD dll,由在 NTVDM 内运行的 DOS 程序加载。 该 dll 使用 C++/CLI 并引用 .NET 程序集。

总而言之,加载过程是这样的:

  NTVDM runs:
    prntsr.com which uses VDD RegisterModule to load:
      prnvdd.dll which references .NET assembly:
         prnlib.dll

prntsr.comprnvdd.dllprnlib.dll文件都在同一个文件夹。

但是,在加载它时,我得到以下异常:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'PRNLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ecf23cee305e91b7' or one of its dependencies. The system cannot find the file specified.
File name: 'PRNLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ecf23cee305e91b7'
   at VDD_Initialise()

=== Pre-bind state information ===
LOG: User = DOMAIN\user
LOG: DisplayName = PRNLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ecf2
3cee305e91b7
 (Fully-specified)
LOG: Appbase = file:///C:/WINDOWS/system32/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Post-policy reference: PRNLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ecf23cee305e91b7
LOG: Attempting download of new URL file:///C:/WINDOWS/system32/PRNLib.DLL.
LOG: Attempting download of new URL file:///C:/WINDOWS/system32/PRNLib/PRNLib.DLL.
LOG: Attempting download of new URL file:///C:/WINDOWS/system32/PRNLib.EXE.
LOG: Attempting download of new URL file:///C:/WINDOWS/system32/PRNLib/PRNLib.EXE.

它只搜索 C:\WINDOWS\system32\ 程序集,我猜这是由于 NTVDM.EXE - 因为这是实际的过程程序集被加载到其中,它将其位置作为 AppBase。

有什么想法可以更改 AppBase 或以其他方式解决此问题吗?

I have a VDD dll that's loaded by a DOS program running inside the NTVDM. This dll uses C++/CLI and references a .NET assembly.

All in all, the loading process is something like this:

  NTVDM runs:
    prntsr.com which uses VDD RegisterModule to load:
      prnvdd.dll which references .NET assembly:
         prnlib.dll

The prntsr.com, prnvdd.dll and prnlib.dll files are all in the same folder.

However, when loading it, I get the following exception:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'PRNLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ecf23cee305e91b7' or one of its dependencies. The system cannot find the file specified.
File name: 'PRNLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ecf23cee305e91b7'
   at VDD_Initialise()

=== Pre-bind state information ===
LOG: User = DOMAIN\user
LOG: DisplayName = PRNLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ecf2
3cee305e91b7
 (Fully-specified)
LOG: Appbase = file:///C:/WINDOWS/system32/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Post-policy reference: PRNLib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ecf23cee305e91b7
LOG: Attempting download of new URL file:///C:/WINDOWS/system32/PRNLib.DLL.
LOG: Attempting download of new URL file:///C:/WINDOWS/system32/PRNLib/PRNLib.DLL.
LOG: Attempting download of new URL file:///C:/WINDOWS/system32/PRNLib.EXE.
LOG: Attempting download of new URL file:///C:/WINDOWS/system32/PRNLib/PRNLib.EXE.

It only searches C:\WINDOWS\system32\ for the assembly, which I guess this is due to NTVDM.EXE - as this is the actual process that the assembly is being loaded into, it takes its location as the AppBase.

Any ideas how to change the AppBase or otherwise work around this problem?

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

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

发布评论

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

评论(2

风苍溪 2024-07-20 16:54:55

尝试将 CLR 拉入 ntdvdm 的每个实例确实不是一个好主意...

但如果您将程序集设为共享程序集,效果可能会更好,因为这些程序集存储在标准位置,并且不会相对于应用?

It's really not a good idea to try to pull the CLR into every instance of ntdvdm...

But probably it would work better if you made your assembly a shared assembly, since these are stored in a standard location and not looked for relative to the application?

慕巷 2024-07-20 16:54:55

您应该通过挂钩 AppDomain.AssemblyResolve 事件获得成功并自己做决议。

You should have success by hooking the AppDomain.AssemblyResolve event and doing resolution yourself.

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