
510 N.W.2d 885 (1994)
Denise TATE, Appellant,
v.
Roxanne DERIFIELD and the Tri-County Drug Task Force, Appellees.
No. 93-351.
Supreme Court of Iowa.
January 19, 1994.
Rehearing Denied February 21, 1994.
*886 C.A. Frerichs and Thomas P. Frerichs, Waterloo, for appellant.
James E. Walsh, Jr. and Nathan A. Callahan of Clark, Butler, Walsh & McGivern, Waterloo, for appellees.
Considered by LARSON, P.J., and LAVORATO, SNELL, ANDREASEN, and TERNUS, JJ.
ANDREASEN, Justice.
Plaintiff appeals from the district court's dismissal of her action for damages for loss of spousal consortium. The district court dismissed plaintiff's action ruling that loss of consortium was a derivative claim and could not be brought absent an action by the injured spouse. For reasons stated in this opinion, we affirm.


*887 I. Background.

Denise Tate (Tate) filed a petition seeking damages for loss of consortium resulting from her husband's incarceration. The petition named Roxanne Derifield and the Tri-County Drug Task Force (Task Force) as defendants. The Task Force is an entity created by agreement between several Iowa counties and municipalities to provide for the joint exercise of certain law enforcement powers. See Iowa Code Chapters 28D, 28E (1991). The petition alleged that the Task Force employed Derifield as a confidential informant and in this capacity she knowingly provided false information for the purpose of obtaining a search warrant for the Tate residence. Based on the evidence seized during the search, Tate asserts that her husband, Jerry Tate, was arrested on criminal charges, compelled to plead guilty, and is presently serving a prison sentence. Tate sought compensatory and punitive damages by reason of Derifield's actions.
The Task Force subsequently filed a motion to dismiss on the grounds that Tate's petition failed to state a cause of action because it owed no common law or statutory duty of care to Tate. Following a hearing, the court granted the Task Force's motion and dismissed the entire case. The court treated the motion to dismiss as a motion for summary judgment. Because it concluded that Tate's consortium claim was derivative and because her husband had not brought any action, the court held she was barred from litigating her claim.
Tate then filed a motion to reconsider challenging the court's conclusion that loss of consortium was a derivative right. Tate further argued that the court improperly relied on facts outside the petition to support its order. In response, the Task Force conceded that loss of consortium was not a wholly derivative right, but argued that Tate had no cause of action because her husband had no cause of action against the defendants for the acts leading to his alleged wrongful conviction. The Task Force also urged Tate's cause of action is barred by public policy. The court affirmed its dismissal again ruling that Tate had no cause of action because her husband had no cause of action. Tate appealed.

II. Motion to Dismiss.

The Task Force secured the dismissal of Tate's claim on a motion to dismiss. See Iowa R.Civ.P. 104(b). We will sustain a motion to dismiss only if the petition on its face shows no right of recovery under any state of facts. Leuchtenmacher v. Farm Bureau Mut. Ins. Co., 460 N.W.2d 858, 861 (Iowa 1990); Fitzpatrick v. State, 439 N.W.2d 663, 665 (Iowa 1989). A motion to dismiss admits the well-pleaded facts in the petition and waives any ambiguity or uncertainty. Leuchtenmacher, 460 N.W.2d at 861. We view the allegations of the petition in the light most favorable to the plaintiff. Id.
The court sustained the Task Force's motion to dismiss treating it as a motion for summary judgment. We have held that a "motion to dismiss can neither rely on facts not alleged in the petition (except those of which judicial notice may be taken) nor be aided by an evidentiary hearing." Berger v. General United Group, Inc., 268 N.W.2d 630, 634 (Iowa 1978); see also Leuchtenmacher, 460 N.W.2d at 861. In its ruling, however, the court considered facts contained in Jerry Tate's criminal court file. We have permitted such "speaking" motions only in limited situations. See Warford v. Des Moines Metro. Transit Auth., 381 N.W.2d 622, 624 (Iowa 1986).
Here the court improperly took judicial notice of facts contained in the criminal court file. Troester v. Sisters of Mercy Health Corp., 328 N.W.2d 308, 311 (Iowa 1982). The district court was limited to consideration of the facts alleged in the petition when deciding whether to grant the motion to dismiss. Our review of the court's dismissal ruling is therefore based only upon the facts and circumstances contained in the petition. On appeal we may affirm the district court ruling upon any ground raised in district court even if the ground is not one relied upon by the court. Fitzpatrick, 439 N.W.2d at 665; Berger, 268 N.W.2d at 634. This includes those issues raised at the hearing upon the motion to dismiss and those *888 issues raised in resistance to the motion to reconsider.

III. Public Policy.

We rely upon one of the grounds urged in support of the motion to dismiss. We conclude the court's dismissal of Tate's consortium claim is dictated by public policy. See Pappas v. Clark, 494 N.W.2d 245, 247-48 (Iowa App.1992) (spouse could not recover on consortium claim arising from husband's drug addiction and death); Cole v. Taylor, 301 N.W.2d 766, 768 (Iowa 1981) (spouse could not maintain consortium claim against psychologist for failing to prevent other spouse from committing murder). The petition alleged that the informant's false information was used to obtain an illegal search warrant. Evidence seized from the execution of the warrant led to Jerry Tate's arrest, his conviction upon a plea of guilty, and his imprisonment. Because his responsibility for criminal conduct was established by his conviction, any injury Jerry Tate suffered was a direct result of his own criminal violations.
Although Tate's claim is not derivative, her claim is barred on public policy grounds that apply to her husband.
Under the general rule
a person cannot maintain an action if, in order to establish his cause of action, he must rely, in whole or in part, on an illegal or immoral act or transaction to which he is a party, or to maintain a claim for damages based on his own wrong or caused by his own neglect, ... or where he must base his cause of action, in whole or in part, on a violation by himself of the criminal or penal laws....
Cole, 301 N.W.2d at 768. See 1A C.J.S. Actions § 29, at 386-88 (1985 & Supp.1993).
We conclude it would be wrong as a matter of public policy to allow recovery on a consortium claim which arose from the lawful incarceration of a spouse. Tate's claim for consortium damages was therefore properly dismissed.
AFFIRMED.
