autoguider
autoguider

Reputation: 15

create dll for MaxImDL VB.Net - mainly solved

Found partial Solution: I ran Visual Studio 2019 as administrator. Then I copied Interop.MAxIm.dll to the program directory that contains Maxim_dl.exe. The plugin can now be loaded manually and adds the value 100 to the opened image file. But the messageboxes do not pop up. That is why I call it 'mainly'.

I leave the full story in here just in case some coders may face the same problem.

some years ago I used VB6 for plugin generation. As I cannot run VB6 anymore I wanted to recompile with VS 2019. To give it a try I downloaded from https://diffractionlimited.com/maxim-dl-extras/ Sample VB.Net. Setting for compilation: Any CPU, assembly visibility for COM is checked, .NetFramework 4.0

Compilation results in 2 dll-files: AddConstantNet.dll and Interop.MAxIm.dll. None of the dlls can be loaded by the application. It says: the file does not contain a valid plugin object. Checking in the MAxIm documentation says that the application takes care of registering the dll. Registration via regsrv32 failed because not entry point could be found. When running VS2019 as admin the AddConst..dll is registered in the registry. Loading results in the error that no plugin object can be found. It also did not help to compile with option x86. On the computer .Net versions 2.05727, 3.0,3.5, 4.0 and 4.0 are visible in the registry. I am also in doubt on the values of classID, Interface ID and eventsID. I just took them from the sample. Are these values provided by the application so that it identifies the correct object? Who is going to set these values? I have the feeling that the VB6 dlls are very much different to VS2019 dll, which is assembly based. ComClassAttribute, as recommended in the advice below has been applied.

Seems that constructor is not executed as the message box did not pop up.

Modyfied code in DoMadal by a MessageBox to ensure that the error message is not caused by the unability to load an image. It seems that this is not the root cause for the error message.

Is it adviseable to try the coding in C# ?

Here for reference the VB.NET code

<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`

Upvotes: 0

Views: 87

Answers (0)

Related Questions