joystick.cs
using System;
using Microsoft.DirectX.DirectInput;
namespace gameproject
{
///
/// Description of device.
///
SetCooperativeLevel
takes System.Windows.Forms.Control
object as a first parameter (where you have null), so you should still reference assembly where this class is defined in your application. Add reference do System.Windows.Forms.dll from your app/game and try then. If code you are using is using some other classes that you haven't referenced under the hood, it's ok, but when they are public (like they are parameter or are returned from methods you are calling), you have to reference assemblies in which those types are defined.
Similar stackoverflow post: Debugging error "The Type 'xx' is defined in an assembly that is not referenced"