Create a C# console application in Visual Studio

This topic describes the steps needed to configure a C# console application in Visual Studio.

Create the Visual Studio project

  1. Create a C# console application in Visual Studio.

  2. Download the 64 bit version of PrimoBurner for .NET. The file you need will have a name similar to PrimoBurner.NET.4.5.0.x64.Demo.zip (the version may be different).

  3. Unzip in a location of your choice, then copy the file PrimoBurner.clr4.x64.dll, PrimoBurner.clr4.x64.xml and PrimoBurner64.dll from the lib directory to the project’s directory.

    Note: Technically you do not need the PrimoBurner.clr4.x64.xml. The XML file contains the PrimoBurner API documentation which Visual Studio understands and will show to you while you are coding.

  4. Switch to the project in Visual Studio and add a reference to PrimoBurner.clr4.x64.dll.

  5. Add the PrimoBurner64.dll to your project simply as a file, open file properties, and set the ‘Copy to Output Directory’ to ‘Copy if newer’, so it is copied to the output directory automatically. The PrimoBurner.clr4.x64.dll needs PrimoBurner64.dll and will not work without it.

  6. In Visual Studio, select ‘BUILD | Configuration Manager’ from the menu, then add the ‘x64′ platform to the solution platforms.

  7. Replace the contents of Program.cs with this code:

using System;

using PrimoSoftware.Burner;

namespace EnumerateDevices
{
    class Program
    {
        static void Main(string[] args)
        {
            // Initialize PrimoBurner
            Library.Initialize();

            // Set license. To run PrimoBurner in demo mode, comment the next line out
            Library.SetLicense("license-xml-string");

            // Enumerate CD \ DVD \ BD devices
            using (var engine = new Engine())
            {
                // Initialize engine
                engine.Initialize();

                // Create device enumerator
                using (var enumerator = engine.CreateDeviceEnumerator())
                {
                    for (int i = 0; i < enumerator.Count; i++)
                    {
                        // Create a device. Do not ask for exclusive access.
                        var device = enumerator.CreateDevice(i, false);
                        if (null != device)
                        {
                            Console.WriteLine("({0}:) - {1}",
                                device.DriveLetter, device.Description);
                        }
                    }
                }

                // Terminate engine
                engine.Shutdown();
            }

            Library.Shutdown();
        }
    }
}

Run the application

  1. Run the application in Visual Studio. You should see a list of burner devices printed in the console.

Troubleshooting

  • You may get a DllNotFoundException exception: Unable to load DLL ‘PrimoBurner64.dll': The specified module could not be found. To fix this, copy the file PrimoBurner64.dll to bin\x64\Debug under the project’s directory.


Last updated on December 4th, 2015 12:00:00 AM