Problems distributing NeroCOM app

I have a VB.Net app that uses NeroCOM which runs fine on my development machine. I have a production environment where I have installed Nero 6, but when I install my app I get an InvalidCastException from the following code:

        m_DVDControl = New NeroClass

        Dim devices As NeroDrives
        devices = m_DVDControl.GetDrives(NERO_MEDIA_TYPE.NERO_MEDIA_DVD_M Or NERO_MEDIA_TYPE.NERO_MEDIA_DVD_P)

        If devices.Count > 0 Then
            m_DVDDrive = CType(devices.Item(0), NeroDrive)
        Else
            LogText("Unable to find DVD burner")
        End If

        Dim drives As NeroDrives = m_DVDControl.GetDrives(NERO_MEDIA_TYPE.NERO_MEDIA_DVD_ANY)

        For i As Integer = 0 To drives.Count - 1
            If drives.Item(i).Capabilities = (drives.Item(i).Capabilities Or NERO_CAPABILITIES.NERO_CAP_IMAGE_RECORDER) Then
                m_ImageRecorder = CType(drives.Item(i), NeroDrive)
            End If
        Next

        If m_ImageRecorder Is Nothing Then
            LogText("Unable to find image recording device")
        End If

I copied the NeroFiddlesCOM.NET app to my production environment and it runs fine. I tried to set up the references in my VB.Net the same as in NeroFiddlesCOM.NET – one reference to Interop.NEROLib.dll and one reference to Interop.NeroVisionAPI.dll. I copied these files out of the NeroFiddlesCOM.NET folder because I couldn’t find NeroLib.dll or NeroVisionAPI.dll. For some reason in my project the references say Interop.NEROLib and Interop.NeroVisionAPI whereas in the NeroFiddlesCOM.NET they just say NEROLib and NeroVisionAPI.

I can’t find NeroLib.dll or NeroVisionAPI.dll on my pc or in the nero sdk folder (v1.06). I’m guessing that maybe I need to tell .NET to reference these, and it will generate the Interop automatically?

On a side note, the NeroCOM documentation is way too sparse and the NeroFiddlesCOM.NET sample doesn’t even exercise all the NeroCOM functionality. All the other DVD burning libraries I’ve used make sure to exercise all functionality in the sample programs so that its completely clear how things work. The NeroFiddlesCOM.NET doesn’t even have functionality for selecting a group of files to burn to DVD – you must start from an image or an existing disc.

I managed to narrow down the InvalidCastException to the following line:


m_DVDDrive = CType(devices.Item(0), NeroDrive)

I have to convert this from INeroDrive to NeroDrive because the INeroDrive interface doesn’t have any events defined, and I need to handle them.

I was able to fix the references by deleting my old references and instead adding a reference directly to c:\program files\ahead
ero
erocom.dll. Unfortunately this didn’t fix the InvalidCastException. I noticed another forum post noting that this can happen when there is a version mismatch, but I have verified that Nero 6.6.0.18 is installed on both my development machine and the production environment.

I suppose I’ll try contacting Nero support.

Well, finally fixed my own problem. I stopped using the NeroDrive class and instead used a combination of the INeroDrive3 interface (INeroDrive doesn’t have the EraseDisc or BurnImage2 methods) and the _INeroDriveEvents_Event interface. I use the INeroDrive3 to start the operations, then catch the events with the _INeroDriveEvents_Event interface. For some reason neither of these pop up in intellisense, and are greyed out in the object browser, but they work fine with the latest version of NeroCOM. Convoluted solution, but it works!