According to the method of the invention, two substrates (1a,1b) are provided, each comprising metal contact structures such as contact pads (5) configured to realize an electrical connection between the substrates in a wafer-to-wafer bonding process. Initially the contact structures are electrically isolated from each other by a layer (6;6+7) of dielectric material. According to the invention, prior to bonding a dielectric bonding layer (16) is produced on each substrate, and openings (17) are produced in the bonding layer, the openings lying within the surface area of the respective contact ...