I can't send a midi message to a hardware device, what am I doing wrong?

I want to make a midi editor for a hardware synthesizer.

The host application crashes immediately with MidiOutput::sendMessageNow().

class ExampleAudioProcessor : public AudioProcessor{

        MidiOutput *midiOutput;   

ExampleAudioProcessor::ExampleAudioProcessor(){ // constructor

    midiOutput -> openDevice(0); // Roland USB MIDI Interface UM-ONE

void ExampleAudioProcessorEditor::sliderValueChanged(Slider *slider){

    MidiMessage message = MidiMessage::controllerEvent(1, 1, midiSlider.getValue());
    processor.midiOutput -> sendMessageNow(message); // host crashes here

add some breakpoints and debug.
Chances are your MidiOutput is a nullptr. Post your full code too.

Opening a device should be:

midiOutput = MidiOutput::openDevice(0);

Thanks, I got it to work.