OPINION
Aftеr a court trial in Ramsey County District Court, appellant Scott Edward Cannady was convicted of 23 counts of possessing child pornography in violation of Minn.Stat. § 617.247, subd. 4(a) (2006), based on photographic images found on his computer. Cannady appealed his conviction, arguing that Minn.Stat. § 617.247, subd. 8 (2006), an affirmative defense provision, unconstitutionally shifts thе burden of production and persuasion to the defendant on the element of age of the persons depicted in the alleged pornographic images. The court of appeals affirmed Can-nady’s convictions, relying on its 2002 decision in
State v. Myrland,
which upheld the constitutionality of section 617.247, subdivision 8, on the basis that only the burden of prоduction is shifted to the defendant and not the burden of persuasion.
This appeal arises out of the following events. In December of 2003, St. Paul police executed a search warrant at Can-nady’s home. As a rеsult of the search, police seized and forensically searched the hard drive of Cannady’s computer. Analysis of the computer hard drive revealed what were determined to be a number of photographic images of what was thought to be child pornography. On March 16, 2004, the Ramsey County Attorney’s office charged Cannady with 25 counts of possession of child pornography in violation of section 617.247, subdivision 4(a). Each count involved a separate image of an alleged minor found on the computer and described in detail a sexual act taking place in the image. Before trial, Cannady moved to dismiss the complaint on constitutional grounds, аrguing that, among other things, section 617.247, subdivision 8, violates the U.S. and Minnesota Constitutions by shifting the burden of production and persuasion to the defendant on the element of the age of the person depicted in the photographic image alleged to contain child pornography. 1 The state opposed Cannady’s motion, asserting that the court of appeals held the statute constitutional in Myrland. The trial court denied Cannady’s motion.
After the trial court dismissed Canna-dy’s motion, Cannady gave notice of his intent to rely on the affirmative defense in section 617.247, subdivision 8. On Septem *406 ber 7, 2004, while expressly preserving his right to appeal the constitutionality of section 617.247, Cannady waived his right to a jury trial and agreed to a court trial. As part of the trial, the parties stipulated to the admission of 16 exhibits into evidence, including the complaint, the police reports, and the photographic images constituting the alleged child pornography. Cannady made clear to the court that, although he stipulated to the police reports and that the police found the photographs on the computer, he was not conceding “the age of the people in the photographs,” but instead was “leaving that for the Court to decide.” Cannady again asserted the affirmative defense found in section 617.457, subdivision 8, and stated that he was “not conceding the element оf age, and expects that to be an element proven by the State.” Cannady did not testify or otherwise offer any evidence in his defense.
On September 20, 2004, the trial court issued its findings of fact, conclusions of law, and guilty verdicts on 28 counts and verdicts of not guilty on the remaining two. The court also put its findings and the verdicts on the record. In doing so, the court noted that, although Cannady asserted the statutory affirmative defense, “[t]he burden of proof remained with the State to prove beyond a reasonable doubt that each photograph contained * * * pornography involving a minor.” The court further noted that the state had proved the element of age beyond a reasonable doubt based on the physical depiction of the persons in the photographs and how the photographs were described (e.g., “prel3”). The court made no mention of the effect, if any, of Cannady’s invocation of the affirmative defense.
On appeal to the court of appeals, Cаn-nady challenged the constitutionality of the affirmative defense in section 617.457, subdivision 8, and the court’s earlier decision in
Myrland. State v. Cannady,
No. A-05-811,
I.
Statutes are presumed constitutional, and we exercise our power to declаre a statute unconstitutional with extreme caution and only when absolutely necessary.
In re Haggerty,
Section 617.247, subdivision 4, makes possession of child pornography a felony: “A person who possesses a pornographic work or a computer disk or comрuter * * * containing a pornographic work, knowing or with reason to know its content and character, is guilty of a felony.” The definition of “pornographic work” is as follows:
(f) “Pornographic work” means:
(1) an original or reproduction of a picture, film, photograph, negative, slide, videotape, videodisc, or drawing of a sexual performance involving a minor; or
(2) any visual depiction, including any photograph, film, video, picture, drawing, negative, slide, or computer-generated image or picture, whether made or produced by electronic, mechanical, or other means that:
(i) uses a minor to depict actual or simulated sexual conduct;
(ii) has been created, adapted, or modified to appear that an identifiable minor is engaging in sexual conduct; or
*407 (iii) is advertised, promoted, presented, described, or distributed in such a manner that conveys the impression that the material is or contains a visual depiction of a minor engaging in sexual conduct.
For the purposes of this paragraph, an identifiable minor is a person who was a minor at the time the depiction was created or altered, whose image is used to create the visual depiction.
Minn.Stat. § 617.246, subd. 1(f) (2006) (emphasis added). In all cases exceрt under section 617.246, subdivision l(f)(2)(iii), the state must prove, as an essential element of its case, that the person or persons in the pornographic work are minors. 2
Section 617.247, subdivision 8, provides that, “It shall be an affirmative defense to a charge of violating this section that the pornographic work was produced using only persons who were 18 years or older.” (Emphasis added.) Cannady argues that the statute’s language is plain and leavеs no discretion regarding whether age is an affirmative defense because it uses the word “shall,” which is mandatory. Minn. Stat. § 645.44, subd. 16 (2004). Thus, he concludes that the statute violates a defendant’s right to due process because it requires the defendant to affirmatively disprove one of the essential elements of the crime, specifically that the persons in the pictures are minors. In response, the state argues that, despite the language of the statute, subdivision 8 is “merely advisory” because the legislature “cannot shift any burden of proving age, an element of the offense, to the defense.”
In Minnesota, defendants bear the burden of production when asserting an “affirmativе defense.”
State v. Auchampach,
Given the plain language of subdivision 8, including the legislature’s use of the term of art “affirmative defense,” we conclude that the legislature intended subdivision 8 to be, and it in fact is, an affirmative defense.
But the legislature did not indicate in subdivision 8 whether the affirmative defense shifts thе burden of production or the burden of persuasion on the element of age to the defendant. The court of appeals in
Myrland
concluded that if the affirmative defense shifted the burden of
*408
production, it would be constitutional, but if it shifted the burden of persuasion, it would be unconstitutional.
But the
Myrland
court did not consider what would haрpen if a defendant fails to make out a prima facie case on the element of age, which in this case is an essential element of the crime. It is well-established law that a defendant’s failure to meet his or her burden of production on a defense prohibits the assertion of that defense.
State v. Yang,
II.
When we hold a statute to be unconstitutional, we invalidate only as much of the law as is unconstitutional. Minn.Stat. § 645.20 (2004);
State v. Shattuck,
The legislature has stated that its policy and intent, in enacting section 617.247,was “to penalize possession of pornographic work[s] depicting sexual conduct which involve minors or appears to involve minors in order to protect the identity of minors who are victimized by involvement in the pornographic work.” Minn.Stat. § 617.247, subd. 1. The affirmative defense in section 617.247, subdivision 8, is the only portion of section 617.247 that shifts the burden of persuasion to the defendant on the elemеnt of age and thus is the only portion of the statute that is unconstitutional. By severing subdivision 8 from the rest of the statute and striking only that portion, we maintain the rest of section 617.247,which criminalizes possession of child pornography as intended by the legislature.
III.
Our determination that section 617.247,subdivision 8, is unconstitutional does not end our inquiry. A deprivation of rights in a сriminal trial may be harmless error, even though it is a constitutional violation.
Arizona v. Fulminante,
499
*409
U.S. 279, 306,
The United States Supreme Court has held that the harmless-еrror analysis applies to errors that occurred during the trial that can be “quantitatively assessed” in the context of the rest of the trial and the evidence presented.
Fulminante,
Even in cases in which the Court has invalidated a state statute that was related to the defendant’s trial, the Court has used the harmless-error test.
Id.
at 307,
So, too, in this case Cannady was not prejudiced by the existence of section 617.247, subdivision 8. Cannady asserted the affirmative defense, without prеsenting any evidence that the persons depicted in the photographic images were 18 years or older. The record, however, indicates that the trial court not only considered the issue of age, despite Cannady’s failure to meet his burden of production, it required the state to prove beyond a reasonablе doubt that the photographs included minors. The court found Cannady guilty on 23' of the 25 counts beyond a reasonable doubt, made a clear record, both in writing and verbally; indicating that the state had met its burden of proving age beyond a reasonable doubt, and explained in some detail exactly how the state had met that burden. The cоurt noted:
I have found the Defendant, Scott Can-nady, not guilty of Counts 6 and 11, as I did not find that the evidence was sufficient to prove beyond a reasonablé doubt that those photographs in Mr. Cannady’s possession constituted child pornography. However, I found, as it relates to photographs 1 through 5, 7 through 10 and then 12 through 25, that the State did prove bеyond a reasonable doubt that each of those photographic *410 images constitute child pornography. * * * [Tjhese photographs include a minor, a subject under the age of 18. My conclusion that the State proved that element beyond a reasonable doubt is two-fold: One, the actual photograph, the physical facial depiction of the child, as well as the categorization of the photograph * * * how- the photographs were listed, how they were described, whether it be “prel3,” “prel4,” “little girl,” “preteen Lolita.”
Thus, despite the fact that Cannady asserted the affirmative defense in section 617.247, subdivision 8, the trial court unequivocally required the, state to prove the elements of the offense beyond a reasonable doubt.
Cf. State v. Ayers,
Affirmed in part, reversed in part.
Notes
. Cannady also argued that section 617.247, subdivision 4, is overbroad, in violation of the First Amendment to the U.S. Constitution. Cannady did not raise that argument on appeal and it is therefore not before us.
. In this case, as in
State v. Fingal,
