A heat exchanger, particularly a charge air heat exchanger or exhaust gas heat exchanger, is provided for the heat exchange between a first fluid, particularly a charge air, or an exhaust gas, and a second fluid, particularly a coolant, comprising the following: heat exchanging guides for the first and second fluids, the guides being separated from each other in the core, the core having a plurality of flow channels through which the first fluid flows, and a housing that receives the flow channels and through which the second fluid flows at least one compartment lid, which is flow-connected to the flow channels, and a base that is attached to the compartment lid and that is equipped with one or more passage openings for flow channels. In order to achieve an advantageous connection of the compartment lid to the base, particularly in case the compartment lid and the base are made of different materials, the invention provides that the compartment lid is attached to the base via one or more connections as a bolted connection and/or a slotted crimping.