我正在与一个非常奇怪的现象作斗争。
我正在使用一个运行在IIS 6.0 SP2上的遗留web应用程序,我想让它能够使用。NETAPI(Aspose.Words)。
我写了一篇文章。NET DLL,我可以将其与IIS一起使用
CreateObject("MyDll.MyClass")
以及用VB6构建的类似DLL的二进制文件或可执行文件(带
CreateObject
或对TypeLib的静态项目引用)。
奇怪的是我经历了
不同的行为
取决于加载源。一个过程可以
达到目的
如果。NET dll是
打电话
从一个
VB6二进制
和
失败
如果来自
IIS
.
相同的代码,相同的输入,不同的输出。
我的问题是:
IIS和VB6二进制文件处理COM可见DLL加载的方式是否不同?
我真的看不到我能生产的任何MCVE样品。COM Visible类通过以下几行简单的代码公开:
<InterfaceType(ComInterfaceType.InterfaceIsDual)> Public Interface IComObject
Sub processSomething(docPath as String)
' [...]
End Interface
此外,失败的过程非常特定于包装的API。
Private Function retrieveTOCEntries(ByVal doc As Words.Document, ByVal documentBodyFileURL As String) As TocEntry()
Dim entries As List(Of TocEntry) = New List(Of TocEntry)
For Each field As Words.Fields.Field In doc.Range.Fields
If Not field.Type.Equals(Aspose.Words.Fields.FieldType.FieldPageRef) Then Continue For
Dim pageRef As Words.Fields.FieldPageRef = CType(field, Words.Fields.FieldPageRef)
If pageRef.BookmarkName Is Nothing OrElse Not pageRef.BookmarkName.StartsWith("_Toc") Then Continue For
Dim tocItem As Words.Paragraph = CType(field.Start.GetAncestor(Words.NodeType.Paragraph), Words.Paragraph)
field.Remove()
' Here the change: b could be Nothing with IIS
' and not Nothing with a VB6 binary for the same input
Dim b As Words.Bookmark = doc.Range.Bookmarks(pageRef.BookmarkName)
End For
End Function
我通过检查虚无来解决我的问题
b
,但我仍然对此感到困惑。。。