.NET 程序集未从 NTVDM 加载
我有一个 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.com
、prnvdd.dll
和prnlib.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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试将 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?
您应该通过挂钩 AppDomain.AssemblyResolve 事件获得成功并自己做决议。
You should have success by hooking the AppDomain.AssemblyResolve event and doing resolution yourself.