Nerocom + c# + firing events to display

There seems to be some confusion when firing events in c#. Never having dealt with c#, I am also confused. I have some skeleton code to maybe help in answering this question. Can someone please help me to understand how to fire nero events in c# using nerocom as the example. What do we put and where do we put it using the following skeleton code. Thanks ahead of time.

Curtis

public class Nero : System.Windows.Forms.Form

{
public NEROLib.NeroDrive drive;

public Nero()
{

InitializeComponent();

}

private void InitializeComponent()

{
//initialize components
}

static void Main()
{
Application.Run(new Nero());
}

private void Nero_Load(object Sender, System.EventArgs e)
{

}

private void Burn_Click(object sender, System.EventArgs e)
{

try
{
drive.OnDoneBurn += new NEROLib._INeroDriveEvents_OnDoneBurnEventHandler(drive_OnDoneBurn);
//Burn CD
}
catch(Exception ex)
{
strMessages=strMessages+ex.Message+"
";
edtMessages.Text=strMessages;
}
}

public void drive_OnDoneBurn(ref NEROLib.NERO_BURN_ERROR StatusCode)
{
strMessages=strMessages+"
“+nero.ErrorLog+”
“;
strMessages=strMessages+nero.LastError+”
“;
strMessages=strMessages+“Burn Finished”;
if(StatusCode != NEROLib.NERO_BURN_ERROR.NERO_BURN_OK )
{
strMessages=strMessages+“NOT (” + StatusCode + “)”;
}
strMessages=strMessages+“successfully!”+”
";
edtMessages.Text=strMessages;
Abort.Enabled=true;
Browse.Enabled=true;
Burn.Enabled=true;
progressBar1.Value=0;

}

I guess there is no answer. I will post my attempts and maybe that will be useful to someone else. I have read several articles on delegating and how to treat a com object. I’ve tried placing the creation of the exception in the initialize components functions(I read that in a previous post). What I mean is the drive.OnDoneBurn += new NEROLib._INeroDriveEvents_OnDoneBurnEventHandler(drive_OnDoneBurn);

with no success.

I’ve read the manual for nero com several times and that object is created like so:

Public WithEvents drive as NeroDrive

at the top of the form. What is the equivalent to this in c#?

I have found the solution to use NeroAPI with C# and NeroApiEvents.
See http://club.cdfreaks.com/showthread.php?s=&threadid=91378

Thanks. I am looking at it right now.

no problem, with me functioned this solution

The tutorial was great. Even when using the exact code in the tutorial, the progress bar does not do anything. I think my problem is when I created the new dll. I had no errors when taking it apart and changing things but I think I must be missing something. I am not sure since I was having problem reading the tutorial. From what I can gather You place the NeroCOM.dll in the same directory as tlbimp.exe. Then at the console type:

tlbimp.exe NeroCOM.dll

to get nerolib.dll.

Next in the same directory as ildasm at the console and with nerolib.dll in the same directory type:

ildasm /source nerolib.dll /output=nerolib.il

to get nerolib.il and nerolib.res.

Then replace private to public in all classes that have _SinkHelper in it(open nerolib.il in notepad, do a search, replace).

Then use the new nerolib.il with ilasm in the console like so:

ilasm /dll nerolib.il /output=nerolib_new.dll

Then I think we add this new dll to our project as a reference along with the nerolib.dll.

With this I still am not having any results ,in this case, with the progress bar. Any thoughts. It is likely that I missed something when I was trying to translate the tutorial.

Thanks,

Curtis