You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VB.NET开发MaxImDL插件:已解决部分问题,弹窗仍异常

MaxImDL .NET插件开发问题排查与咨询

背景与问题历程

  • 原VB6开发的MaxImDL插件因VB6无法运行,改用VS2019重构
  • 基于Diffraction Limited官网的VB.Net示例代码开发,编译配置:
    • 目标框架:.Net Framework 4.0
    • 平台目标:Any CPU(后切换x86也无效)
    • 勾选“使程序集COM可见”
  • 编译生成AddConstantNet.dll和Interop.MAxIm.dll,但初始无法加载:
    • MaxImDL提示“文件不包含有效插件对象”
    • 尝试regsrv32注册失败,管理员运行VS2019注册后仍无法加载

当前状态

  • 已实现部分功能:管理员运行VS2019后,将Interop.MAxIm.dll复制到Maxim_dl.exe所在目录,插件可手动加载,且能为打开的图片所有像素值加100
  • 存在异常:所有MessageBox弹窗完全无法弹出,包括构造函数和DoModal方法中添加的调试弹窗

疑问与诉求

  1. 代码中ClassId、InterfaceId、EventsId直接沿用示例值,不确定是否需要由MaxImDL指定特定值
  2. 已应用ComClassAttribute,但仍疑惑VB6与VS2019生成COM DLL的差异点
  3. 咨询是否建议改用C#开发该插件
  4. 寻求解决弹窗无法弹出的方案

附VB.NET代码

<ComClass(PlugIn.ClassId, PlugIn.InterfaceId, PlugIn.EventsId)> _
Public Class PlugIn

#Region "COM GUIDs"
    ' These  GUIDs provide the COM identity for this class 
    ' and its COM interfaces. If you change them, existing 
    ' clients will no longer be able to access the class.
    Public Const ClassId As String = "a1524f94-e3ce-4438-9671-bca0c39d4532"
    Public Const InterfaceId As String = "cb83c68c-3ed9-40e2-8df2-639264b7ffbc"
    Public Const EventsId As String = "73265d4c-16b5-4b3e-bd1a-34eabbd8ae77"
#End Region

    ' A creatable COM class must have a Public Sub New() 
    ' with no parameters, otherwise, the class will not be 
    ' registered in the COM registry and cannot be created 
    ' via CreateObject.
    Public Sub New()
        MyBase.New()
        MsgBox(" Plugin Constructor NEW executed") '<- check on execution constructor
    End Sub

    Public Sub DoModal(ByVal Doc As MaxIm.Document)
        MsgBox(" Plugin has started") '<-------- modification
        Dim Image(,) As Single
        Image = Doc.ImageArray
        Dim W, H, I, J As Integer
        W = Image.GetLength(1)
        H = Image.GetLength(0)
        For I = 0 To H - 1
            For J = 0 To W - 1
                Image(I, J) = Image(I, J) + 100
            Next
        Next
        Doc.ImageArray = Image
    End Sub

    Public ReadOnly Property Name() As String '<-- declaration non auto
        Get
            Return "Add Constant 100 .NET"
        End Get
    End Property

End Class

内容的提问来源于stack exchange,提问作者autoguider

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 07:38:21