1

我有一个 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.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 或以其他方式解决此问题?

4

2 回答 2

0

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

但是,如果您将程序集设为共享程序集,可能会更好,因为这些程序集存储在标准位置而不是相对于应用程序进行查找?

于 2011-01-07T05:46:29.657 回答
0

您应该通过挂钩AppDomain.AssemblyResolve事件并自己进行解析来取得成功。

于 2011-01-07T05:57:43.910 回答