
197 Wis.2d 157 (1995)
540 N.W.2d 189
LAKE BLUFF HOUSING PARTNERS, a Wisconsin limited partnership, Plaintiff-Respondent,[]
v.
CITY OF SOUTH MILWAUKEE and Michael Vesperman, in his capacity as City Building Inspector, Defendants-Appellants-Petitioners.
No. 94-1155.
Supreme Court of Wisconsin.
Oral argument September 7, 1995.
Decided November 20, 1995.
*160 For the defendants-appellants-petitioners there were briefs by Joseph G. Murphy, city attorney, and Murphy & Leonard, South Milwaukee and oral argument by Joseph G. Murphy.
For the plaintiff-respondent there was a brief by Alan Marcuvitz, Debra A. Slater and Weiss, Berzowski, Brady & Donahue, Milwaukee and oral argument by Alan Marcuvitz & Debra A. Slater.
Amicus curiae brief was filed by Curtis A. Witynski, Madison for the League of Wisconsin Municipalities.
ROLAND B. DAY, C.J.
This is a review of a published decision of the court of appeals affirming a judgment of the Circuit Court for Milwaukee County, John E. McCormick, Judge, granting a writ of mandamus ordering the City of South Milwaukee (the City) to issue a building permit to Lake Bluff Housing Partners (Lake Bluff). This case presents the following issue: may a court, through the exercise of discretion, resort to "equitable principles" to supply a "right" to the issuance *161 of a building permit where the building plans submitted did not comply with the applicable zoning and building code requirements, and thereby find a positive and plain duty on the part of the municipality to issue a building permit for a construction that would be in violation of the ordinance. We conclude that the circuit court in this case erred in granting a writ of mandamus in the absence of a clear legal right on the part of Lake Bluff and a positive and plain duty on the part of the City, and therefore reverse the decision of the court of appeals.
The facts in this case are largely undisputed. Lake Bluff, a Wisconsin limited partnership, is a developer of rental properties. In December 1992, Lake Bluff purchased a parcel of land for $294,000 along the shoreline of Lake Michigan in South Milwaukee, intending to construct a multi-family development that would qualify for low income housing tax credits administered by the Wisconsin Housing and Economic Development Authority (WHEDA). The zoning on the parcel was "C-2," a classification allowing the construction of multifamily residential units. Although the parcel had been zoned C-2 since 1965, there were no multi-family units on the land in 1992. Lake Bluff verified through the land's previous owners that the land was zoned C-2, and that such zoning would allow for a multi-family development, before purchasing the land.
Lake Bluff had applied for a tax credit through WHEDA in October, 1992. WHEDA awarded Lake Bluff a $266,903 site-specific tax credit in December, 1992. Later that same month, Lake Bluff paid WHEDA a non-refundable fee of $16,314 to reserve the credit. Lake Bluff then had the property surveyed at a cost of $1,150, and contracted with an architect to prepare project plans at a cost of $29,513. In order to preserve *162 the WHEDA tax credit, Lake Bluff's project had to be built and certificates of occupancy had to issue by December 31, 1994. The trial court found that Lake Bluff would have had to begin construction "immediately" after the issuance of the trial court's May 1994 order granting mandamus in order to complete the project in time.
In February 1993, representatives of Lake Bluff met with the mayor, city administrator, building inspector, city engineer, and district alderperson of South Milwaukee to review initial plans for its project. At this meeting, Lake Bluff proposed building seven apartment buildings on the land, each with space for eight family units.[1] The City confirmed that the property was in a C-2 zone that permitted a multi-family project. However, the City advised Lake Bluff that all construction along the lake bluff required a bluff assessment establishing that the project would not cause bluff erosion. The City also advised Lake Bluff that South Milwaukee's parking requirements had changed and that Lake Bluff would have to modify its plans to meet the new requirements. Lake Bluff subsequently modified its parking plans and commissioned a bluff erosion study costing $4,950.
In a letter to a City of South Milwaukee alderperson dated April 28, 1993, William J. Fox, III, a neighboring landowner, requested that Lake Bluff's land be rezoned from C-2 to R-A. This zoning change *163 would allow for single-family housing, but not for Lake Bluff's proposed multi-family units. On May 6, the City referred Fox's request to its Plan Commission; on May 24, the Plan Commission referred the matter to the South Milwaukee City Attorney for review and comment. The Plan Commission also recommended that no building permits issue while the rezoning request was under consideration. The trial court found that Lake Bluff did not learn that the City was considering a moratorium on the issuance of any building permits for the property or a rezoning until June 22, 1993, and that Lake Bluff did not have an opportunity to participate in the May meetings of the Plan Commission or the Common Council.
On July 6, 1993, the South Milwaukee Common Council adopted resolution number 93-30, pertaining only to the Lake Bluff property, imposing a moratorium on the issuance of any building permits while the Council considered the rezoning request.[2] The Plan Commission then considered the rezoning request at its meeting of July 12, 1993.
On August 5, 1993, the Wisconsin Department of Industry, Labor and Human Relations issued its conditional approval of Lake Bluff's plans. This approval enabled Lake Bluff to seek a "footing and foundation" building permit from the City and subsequently begin construction. Lake Bluff submitted an application for the permit on that same day. Lake Bluff now proposed *164 construction of two buildings: one a three-story building containing 40 units, and the other a two-story building containing 16 units. The City's building inspector denied the permit that same day. The building inspector wrote "per resolution number 93-30 [the moratorium], permit is denied" on Lake Bluff's permit application and returned it to Lake Bluff's representative.
Two days later, in an apparent effort to determine whether the denial was based solely on the moratorium or on some defect in its plans, Lake Bluff wrote to Michael Vesperman, South Milwaukee's building inspector:
Pursuant to our application for a "Footing/Foundation" permit on Thursday, August 5, 1993, . . . it is the understanding of this office that the following additional information will be required:
a. the City Engineer . . . will review the drawings deposited with your office to "verify site/building grades" for conformance,
b. your office will review the drawings deposited with your office for "conformance to required set backs,"
c. two (2) additional sets of drawings are required for application, one (1) additional "State Approved" copy, plus one (1) not necessarily stamped set,
d. evidence of "DILHR Letter of Approval" dated August 5, 1993 for each building, copies of which have been sent directly to your office by DILHR via the U.S. Mail, and

*165 e. Footing/Foundation permit for the above captioned project "has been denied" per [the moratorium] dated July 6, 1993. Any questions concerning this matter should be referred to the City Attorneys office, attention Mr. Joseph Murphy.
Should you be in disagreement with any of the contents of this letter, please notify this writer via facsimile . . . with a hard copy via U.S. mail, prior to the close of business on Monday, August 9, 1993.
The City did not formally respond to this letter.[3] On August 20, Lake Bluff again wrote to the City requesting a specific response to its concerns. On August 24, the City Attorney replied to the August 20 letter, writing, in part:
Please be advised that Mr. Vesperman has not yet reviewed the plans presented for the structural aspects of the property, has not verified the setbacks and zoning compliance and erosion control measures contemplated and the City Engineer has not had the opportunity to check the grading and *166 zoning compliance. Furthermore, the Building Board of Review has not yet reviewed the plans.
Also, please be advised that inasmuch as the moratorium will not allow construction of this project until after November 4, 1993, neither the City Building Inspector nor the City Engineer intends to drop everything else that they are currently engaged in to process this application for a building permit. Your application for a permit will simply have to wait its turn for their attention like everything else that is coming across their desk. If there is some reason that their review ought to be advanced and expedited, please advise me.
Lake Bluff did not reply to the City Attorney's request to be advised "if there is some reason that . . . review ought to be advanced and expedited." Instead, the partnership attempted to resolve its difficulties through the political process. A Lake Bluff general partner wrote letters to the Mayor of South Milwaukee on September 24 and October 7, 1993, requesting the cooperation of the City in consideration of the development plans, and in the scheduling of a Plan Commission meeting at which to discuss alternative solutions[4] to the dispute.
On October 7, the Common Council of the City of South Milwaukee held a public hearing on the rezoning request. On November 2, 1993, the City enacted an ordinance rezoning the Lake Bluff property from C-2 to R-A.[5] On March 10, 1994, Lake Bluff resubmitted its *167 application for a building permit, and also filed a complaint seeking a writ of mandamus to compel issuance of the permit.[6] The complaint alleged that Lake Bluff had acquired vested rights in the C-2 zoning of the property prior to the City's enactment of the change in the zoning, and requested the trial court to issue a writ of mandamus requiring the City to issue Lake Bluff a building permit.
In its answer to the complaint, the City asserted that Lake Bluff's plans failed to comply with the requirements of the former C-2 zoning and other statutory and administrative provisions.[7] It is undisputed that the plans submitted on August 8, 1993, and March *168 10, 1994 were for a building too large to comply with the setback requirements of the C-2 zoning on the parcel.[8] The March 10, 1994 plans were also not in compliance with the then-existing R-A zoning on the land, which prohibited multi-family housing. During the course of the litigation, Lake Bluff sent its architect to the depositions of various City officials. The architect determined the details of the zoning and building code violations, and changed the plans to conform to code by the time the case was heard on April 29, 1994.
The trial court found that "Lake Bluff would suffer significant and irreparable harm if it is not allowed to proceed with its planned construction at the Property immediately" and rendered the following conclusions of law:
Lake Bluff acquired protected vested rights and interests in the Property by virtue of the expenditures *169 it made for the purchase price of the Property, the payment to WHEDA to reserve the low income housing tax credits, the cost of architectural plans and specifications, the survey costs and the costs for the bluff study, all in reliance upon the zoning in existence at the Property at the time that it purchased it.
Lake Bluff acquired its vested rights before South Milwaukee's enactment of the moratorium prohibiting the issuance of building permits at the Property.
South Milwaukee's actions in denying Lake Bluff's application for a building permit were arbitrary, capricious and invalid.
Because it acquired vested rights in the existing C-2 zoning at the property, Lake Bluff is entitled to a Writ of Mandamus directing the Building Inspector to issue a permit allowing it to construct its project at the Property.
South Milwaukee is estopped from raising its belated objections to Lake Bluff's plans.
On April 29, 1994, the trial court granted the writ of mandamus directing the City to issue a building permit to Lake Bluff for its planned development. The City appealed.
The court of appeals, in a two-to-one decision, affirmed the circuit court. See Lake Bluff Housing Partners v. City of South Milwaukee, 188 Wis. 2d 230, 525 N.W.2d 59 (Ct. App. 1994). The majority of the court of appeals held that the circuit court's granting of the writ of mandamus had not been an erroneous exercise of discretion. The majority ruled that although Lake Bluff had never submitted a proposal for a building permit which conformed to the zoning and building code requirements on the property, the partnership had nonetheless acquired a vested right in the former zoning *170 of the land. According to the majority, Wisconsin case law on vested rights and mandamus allowed the consideration of equitable factors in determining the existence of two requirements of a writ of mandamus, a clear legal right and a plain duty.
[1, 2]
Mandamus is an extraordinary legal remedy, available only to parties that can show that the writ is based on a "clear, specific legal right which is free from substantial doubt." Collins v. American Family Mut. Ins. Co., 153 Wis. 2d 477, 483, 451 N.W.2d 429 (1990) (quoting Eisenberg v. ILHR Dept., 59 Wis. 2d 98, 101, 207 N.W.2d 874 (1973)). A party seeking mandamus must also show that the duty sought to be enforced is positive and plain; that substantial damage will result if the duty is not performed; and that no other adequate remedy at law exists. State ex rel. Iushewitz v. Personnel Review Bd., 176 Wis. 2d 706, 711, 500 N.W.2d 634 (1993) (citing Collins, 153 Wis. 2d at 483-84).
[3, 4]
This court will uphold a trial court's granting or denying a writ of mandamus unless the judge erroneously exercised discretion. Miller v. Smith, 100 Wis. 2d 609, 621, 302 N.W.2d 468 (1981); State ex rel. Kurkierewicz v. Cannon, 42 Wis. 2d 368, 375-76, 166 N.W.2d 255 (1969). A judge's discretion in issuing a writ of mandamus is erroneously exercised if based on an erroneous understanding of the law. State ex rel. Althouse v. City of Madison, 79 Wis. 2d 97, 106, 255 N.W.2d 449 (1977).
The trial court in this case granted mandamus in part because it determined that Lake Bluff had obtained vested rights in its building project through its various expenditures made prior to the City's moratorium. The City argues that, under Wisconsin law, a *171 builder must submit an application for a building permit which conforms to applicable zoning and building code requirements in order to obtain vested rights; because Lake Bluff never submitted a conforming application before the change in zoning in the instant case, it never obtained vested rights and mandamus should not have been granted in the absence of any clear right.
In the Building Height Cases, 181 Wis. 519, 195 N.W. 544 (1923), this court established criteria for adjudicating zoning vested rights cases. The court examined three separate fact situations, and ruled on the nature of the vested rights, if any, in each. In the first case, State ex rel. Klefisch v. Wisconsin Telephone Co., a builder had designed and obtained building permits for an addition of five floors to an eight-story building. Id. at 530-31. The builder had incurred various expenses for materials, and had already begun construction, when the Legislature enacted a restriction on the height of structures which would have forbidden the building. Id. at 531. The court held that the builder's "substantial rights had vested" prior to the passage of the restriction, and the builder could proceed with the construction. Id. at 532.
In the second case, State ex rel. Buchholz v. Hotel Wisconsin Realty Co., a builder had planned to construct an addition to a building which would have violated the height restriction, but had not incurred any expenses. Id. The builder did not attempt to obtain a building permit until after the passage of the height restriction, at which time the permit was denied. Id. The court held that the builder's rights in the proposed construction had not vested in that case. Id. at 533.
In the third case, Atkinson v. Piper, a builder had planned, prior to the enactment of the height restriction, *172 a building with a prohibited height of 115 feet. Id. at 533-34. The builder had obtained a building permit and started construction, but the court noted that the builder had not incurred any expense which would be lost if the building were to conform to the new height restriction, and be 100 feet tall instead of 115. Id. at 534. A 4-3 majority held that the builder's rights had nonetheless vested, and allowed the construction of the building at its full height of 115 feet. Id.
Although the court in the Building Height Cases stressed that determining whether rights have vested is "for the most part a matter of individual opinion," id., a common factor in the three cases there considered was the presence or absence of a building permit. In the two cases where a permit had been obtained, the court held that the builder's rights had vested, while in the one case where a permit had not been applied for, the court found no vested rights. From the very beginning of zoning jurisprudence in this state, then, a building permit has been a central factor in determining when a builder's rights have vested.
This court, in State ex rel. Humble Oil & Ref. Co. v. Wahner, 25 Wis. 2d 1, 130 N.W.2d 304 (1964), stated: "Generally, a building permit must be obtained before vested rights arise. Other jurisdictions have held that construction must have begun, that merely applying for a permit, commencing a mandamus action, and even getting a mandamus action are insufficient." Id. at 13 (footnotes omitted). The use of the word "generally" implies that receiving a building permit is not an absolute requirement in the vested rights analysis. In fact, our cases show that a developer must at least apply for a building permit in order to obtain vested rights.
*173 In Rosenberg v. Whitefish Bay, 199 Wis. 214, 215, 225 N.W. 838 (1929), a builder had obtained a change in zoning on a parcel of land to allow construction of an apartment building. The builder then incurred various expenses and prepared plans for the proposed construction. Id. at 216. Fifteen months after the change in zoning, the builder applied for a building permit. The municipality denied the application, informing the builder that it wished to build a park on the parcel of land. Id. The municipality in Rosenberg apparently never alleged that the builder's application did not conform to the requirements of the zoning or building code. The municipality then passed a new zoning ordinance which forbade the builder's proposed construction. Id. This court noted that the builder, like the builder in the third of the Building Height Cases, had incurred expenses in the preparation of building plans. Id. at 217. The court held that the builder's substantial rights had vested before the passing of the ordinance, and that the ordinance could not prevent the construction of the proposed buildings. Id.
In the instant case, as in Rosenberg, the builder had applied for, but not received, a building permit; Rosenberg would thus appear to support Lake Bluff's position that simply applying for a permit is sufficient to allow rights to vest. However, our cases also state that the application for a building permit must be in conformance with all zoning and building code requirements. In State ex rel. Schroedel v. Pagels, 257 Wis. 376, 378, 43 N.W.2d 349 (1950), a builder planned to construct an apartment building on a parcel of land zoned for such use. After discussing his plans with municipal officials, the builder was informed of new garage requirements for apartments, and changed the plans to comply with the requirements. The builder *174 then learned that the municipality planned to rezone the parcel of land; the builder promptly submitted an application for a building permit, "together with complete plans and specifications which had been approved by the Wisconsin industrial commission as conforming to the state code." Id. at 378-79. The municipality denied the request because of its plans to change the zoning on the parcel, and because it claimed that the builder's plans did not comply with certain local requirements for a sewer connection. Id. at 379. The trial court, however, specifically found that the plans did comply with the local requirements and would "call for the erection of apartment buildings which would be valid and lawful under the zoning laws" as they existed at the time, of the filing of the plans. Id. at 380, 382. This court held that the builder's rights in the construction project had vested. Id. at 382.
Requiring strict and complete conformance with applicable zoning and building code requirements is in line with the general rule:
In order for the applicant [for mandamus] to have a right to have the sought after act or action performed, strict and complete compliance with all necessary and applicable provisions of the relevant ordinance is required. Lack of compliance with conditions precedent not only has the effect of precluding a clear legal duty on the part of the administrative officer or body, it deprives such officer or body of the power to perform the act.
4 Edward H. Ziegler, Jr., Rathkopf's The Law of Zoning and Planning 44.04[1], at 44-14 to 44-15 (4th ed. 1956 & Supp. 1994) (footnotes omitted); see also Eugene McQuillin, Municipal Corporations § 25.157, at 703 (3d ed. 1991) ("No rights may vest where either the application *175 submitted or the permit issued fails to conform to the existing zoning or building regulations.").
[5, 6]
Requiring an application for a building permit which conforms to applicable zoning or building code requirements in order to show a clear legal right also serves the goals of the vested rights doctrine. The theory behind the vested rights doctrine is that a builder is proceeding on the basis of a reasonable expectation. See State ex rel. Cities Serv. Oil Co. v. Board of Appeals, 21 Wis. 2d 516, 528-29, 124 N.W.2d 809 (1963); McQuillin, supra, § 25.157, at 701 ("[The vested rights] doctrine is also applicable to an applicant for a permit who acted in reliance on the ordinance as it existed at the time of his or her application for a permit."). Vested rights should only be obtained on the basis of strict and complete compliance with zoning and building code requirements, because a builder's proceeding in violation of applicable requirements is not reasonable.
In this case, it is undisputed that Lake Bluff never submitted an application for a building permit which complied with either the new single-family zoning or with the former C-2 zoning. The record demonstrates that the plans submitted pursuant to Lake Bluff's applications for a building permit on August 8, 1993, and March 10, 1994 were, at least, not in compliance with the set-back requirements of the C-2 zoning. In fact, the plans proposed a building too large for the zoning on the lot. The trial court, in its findings of fact, acknowledged that the plans as first submitted were nonconforming by finding that "[s]ince the start of this lawsuit, Lake Bluff has changed its plans to correct the deficiencies belatedly identified by South Milwaukee in Lake Bluff's permit application." Of course, the plans submitted by Lake Bluff on March 10, 1994, also did *176 not comply with the residential zoning then in effect on the parcel of land, because they proposed a multi-family apartment complex.
Lake Bluff argues that, in the words of the court of appeals majority in the instant case, "conceptually, vested rights can be separated from zoning compliance." Lake Bluff, 188 Wis. 2d at 250. However, neither Lake Bluff nor the court of appeals majority cite a single Wisconsin case in which a court found that a builder's rights had vested when the builder had not submitted an application for a building permit which conformed to code. In fact, the line of vested rights cases, including the Building Height Cases, Rosenberg, and Schroedel, holds exactly the opposite.
Lake Bluff contends that State ex rel. Humble Oil & Refining Co. v. Wahner, 25 Wis. 2d 1, 130 N.W.2d 304 (1964), supports the general proposition that a property owner's noncompliance may not be fatal to a mandamus claim. A builder, Humble, sought to construct a gas station. According to local zoning requirements, the construction of such stations was not permitted on the land in question, but the stations could be constructed with the approval of the town board of appeals. Id. at 3-4. Humble made several attempts at securing a permit, but each time the town refused the request without explanation. Id. at 3, 5. Humble then filed suit against the town; shortly afterwards, the town changed its zoning requirements on the land in question, forbidding the construction of gas stations. Id. at 6.
[7]
This court first determined that the original zoning was invalid for failing to provide proper standards to guide the town board of appeals in ruling on petitions. Id. at 11. In addition, the court held that the *177 builder's rights had not vested. Id. at 12-13. The court distinguished Schroedel on the grounds that Humble's applications for building permits never proposed a use which was allowed under the existing zoningas already noted, gas stations could only be constructed on the land with the approval of the town board of appeals. Id. The court concluded:
Although since its first petition . . . Humble had obtained an option on the subject property, had exercised the option, and had gone to considerable expense in developing plans for the development of the site, Humble had no vested rights as of the time when the new ordinance was passed by the town board.
Id. at 13. By denying vested rights to a builder who submitted an application for a building permit that did not propose a permitted use under existing zoning, Humble is squarely in line with the general rule in Wisconsin: in order for a developer's rights to vest, the developer must submit an application for a building permit which conforms to the zoning or building code requirements in effect at the time of the application.
Ultimately, the court in Humble concluded that Humble's writ of mandamus should be granted, because the original ordinance was defective:
Since this court has concluded that the portion of the ordinance permitting filling stations but requiring board approval of each permit is invalid as to this attempted delegation of authority to the board, Humble had a clear legal right to the issuance of the requested permit and the appellant building inspector had a positive and plain duty to issue the permit. Under the circumstances Humble was clearly entitled to the writ of mandamus. *178 Humble, 25 Wis. 2d at 16. The reason for this holding is clear: but for the invalid portion of the municipality's original ordinance, Humble's applications would have been conforming. As a result, Humble had a clear legal right to a permit.
[8]
Thus, Humble does not stand for the proposition, advanced by the majority of the court of appeals, that a court may employ equitable considerations in determining the existence of a "clear legal right" in an action for a writ of mandamus. See Lake Bluff, 188 Wis. 2d at 254. The court in Humble did not apply equity to supply or create a clear legal right; it only looked to the equities for the limited purpose of determining that the municipality's second zoning ordinance, as amended after the filing of the lawsuit in order to prohibit Humble's requested use, could not bar the builder's right to a permit. Humble, 25 Wis. 2d at 13-15. Similarly, in Schroedel, the court only looked to equitable considerations in discussing the nature of the municipality's change in the zoning ordinance, after having found that the builder had submitted a plan conforming to the former requirements and thus had a clear right to a permit. See Schroedel, 257 Wis. 2d at 383 84. This result is in line with the criteria for mandamus found in Neu v. Voege, 96 Wis. 489, 492-93, 71 N.W. 880 (1897):
To be sure, the granting or refusing of a writ of mandamus is somewhat discretionary, but when the application therefor is made by a person to enforce a clear legal right; the duty sought to be enforced is positive and plain; the applicant for the writ shows that he will be substantially damaged by nonperformance of such duty; and there is not other adequate specific legal remedy for the threatened *179 injury, and no laches on the part of such applicant, and no special reasons exist rendering a resort on his part to the remedy, under the circumstances, inequitable, to refuse to issue the writ constitutes an abuse of judicial discretion.
As the court of appeals noted in Keane v. St. Francis Hospital, 186 Wis. 2d 637, 647, 522 N.W.2d 517 (Ct. App. 1994): "The theme throughout the caselaw is that the four criteria preceding the 'and no' clauses establish the legal prerequisites that must be satisfied before a trial court can grant the writ, while the `and no' clauses then carry the trial court to additional discretionary, equitable considerations." The existence of a clear legal right, then, is not to be determined through the use of equitable principles.
Lake Bluff contends that equitable considerations should require this court to nullify the City's change in the zoning ordinance, as did the court in Humble. However, the amendment to the ordinance in Humble occurred after the builder had filed suit against the town. The court noted that allowing the amendment "would be tantamount to approving the proposition that every time a party came close to successfully challenging a town and its zoning board on its zoning actions, his gains could be legislated away by the enactment of an amendment to the ordinance." Humble, 25 Wis. 2d at 15. This concern is not present in the instant case, because here the ordinance was changed before the filing of the suit, not after. The equities in the present situation do not require us to provide the remedy given in Humble. In addition, there is nothing in the C-2 ordinance that is invalid, as there was in the ordinance in Humble.
*180 [9]
Lake Bluff also notes that the town in Humble raised noncompliance with building requirements as an argument against granting mandamus, but this court ruled that the town had waived any noncompliance by first raising the argument on appeal and by failing to give a reason for the denial of Humble's application for a permit on three separate occasions. Id. at 16. The issue of zoning compliance in the present matter is distinguishable from Humble. First, the City did not raise Lake Bluff's noncompliance for the first time on appeal, but rather immediately, in its answer to the complaint. Second, the City, unlike the municipality in Humble, did provide reasons for the denial of the permit. The City first informed Lake Bluff that its permit was denied because of the moratorium. As already noted, the legality of this moratorium has not been questioned, and we consider it as valid for purposes of this appeal. South Milwaukee's City Attorney also informed Lake Bluff by letter that the moratorium was delaying the review of the plans, and that Lake Bluff should inform the City if it wanted the review of the plans to be expedited. But Lake Bluff ignored this request, and chose instead to contact local officials, and propose alternative plans, in an attempt to avoid a change in zoning. Third, as Judge Fine noted in his dissent to the court of appeals opinion in the instant case, even if the City had issued the requested building permit, that permit could not have authorized Lake Bluff to develop its property in conformity with the application filed August 5th, because a building permit grants no right to an unlawful use. Lake Bluff, 188 Wis. 2d at 255-56 (Fine, J., dissenting) (citing Jelinski v. Eggers, 34 Wis. 2d 85, 93, 148 N.W.2d 750 (1967)). In Humble the town only alleged a failure to comply with *181 "formal filing requirements," and the court noted "[n]o evidence was produced by the town to show that any vital documents had not been filed." Humble, 25 Wis. 2d at 16. The seriousness of the noncompliance in the present case is of a greater magnitude, and not merely alleged but clearly demonstrated in the record. For these reasons, we conclude the City did not waive Lake Bluff's non-compliance.
Lake Bluff also cites State ex rel. Lake Drive Baptist Church v. Village of Bayside Bd. of Trustees, 12 Wis. 2d 585, 108 N.W.2d 288 (1961), for the proposition that the presence or absence of a building permit is not crucial to the determination of vested rights. Lake Bluff notes that, although the Lake Drive Baptist court did not find any vested rights on the part of the builder, the court's discussion of the vested rights issue mentioned only the absence of any significant expenses on the part of the builder, not the absence of a building permit. However, in Lake Drive Baptist, as in Schroedel, the trial court made a specific finding that the plans conformed to local building codes: "The [trial] court found that there is no issue between the parties concerning the adequacy of the proposed building according to the plans . . . , structurally, architecturally, or otherwise. . . . The plans and specifications comply with local building-code requirements and state law." Lake Drive Baptist, 12 Wis. 2d at 592-93. The issue of compliance was not before the Lake Drive Baptist court, and the case therefore provides no support for Lake Bluff's contentions. In any event, three years after the Lake Drive Baptist case, the Humble court determined that a builder who had incurred substantial expenses still had no vested rights because of the lack of a building permit. Humble, 25 Wis. 2d at 13. The Lake Drive Baptist case does not deviate from the *182 general pattern of requiring at least an application for a building permit which complies with applicable building codes in order for rights to vest.
From our examination of relevant law, it is clear that Lake Bluff obtained no vested rights, because it never submitted an application for a building permit conforming to the zoning and building code requirements in effect at the time of the application. Our cases have consistently held that no rights vest in such an instance. Lake Bluff did not possess the "clear, specific legal right which is free from substantial doubt" that is required in an action for mandamus. Collins v. American Family Mut. Ins. Co., 153 Wis. 2d 477, 483, 451 N.W.2d 429 (1990) (quoting Eisenberg v. ILHR Dept., 59 Wis. 2d 98, 101, 207 N.W.2d 874 (1973)).
[10]
We conclude that the trial court made its determination that mandamus could lie based on an erroneous understanding of the law. Because a discretionary determination must be based on a correct understanding of the law, see Althouse, 79 Wis. 2d at 106, we hold that the trial judge's granting of mandamus was an erroneous exercise of discretion.
By the Court.The decision of the court of appeals is reversed, and the cause remanded to the circuit court with instructions to quash the writ.
NOTES
[]  Motion for Reconsideration denied January 23, 1996.
[1]  Lake Bluff ultimately proposed three separate plans for development of its property. As noted below, by August 1993, Lake Bluff had changed its proposed construction to a plan for two buildings, totalling 56 units, and in September 1993, Lake Bluff proposed constructing a single three-story building with 68 units. The August plans were later resubmitted in March of 1994, along with Lake Bluff's complaint for a writ of mandamus.
[2]  At oral argument before both this Court and the court of appeals, counsel for defendant stated that this moratorium was of questionable legality, although it was counsel's opinion that the moratorium would have been legal if enacted by ordinance. Because the moratorium was never challenged, and is not challenged here, we will accept it as valid for the purposes of this review.
[3]  Although it is undisputed that the City never provided a written reply to Lake Bluff's letter, there is some dispute as to whether the City responded to Lake Bluff's inquiries by other means. The trial court found that the City "did not notify Lake Bluff of any deficiencies in its plans, specifications and application" and that the City only identified the deficiencies after the commencement of Lake Bluff's lawsuit on March 10, 1994. However, the record also shows that the City's engineer, Michael Lemens, recalled that he contacted Ron Klaas, a representative of Lake Bluff, during September or October 1993, and that Lemens informed Klaas that problems existed with Lake Bluff's proposed plans, including a problem with the setback requirement.
[4]  As part of its attempt at political persuasion in September, Lake Bluff proposed still another plan, for a single threestory building with 68 units. Lake Bluff never applied for a building permit for this proposal.
[5]  This ordinance was applicable only to Lake Bluff's property. However, the record shows that the City also considered rezoning an adjacent parcel of land from commercial to residential at the same time, but decided against the change when it was informed that the parcel, a former site of two large industrial waste pits, would be subject to an environmental cleanup.
[6]  The proposed building plans were the same plans submitted by Lake Bluff on August 8, 1993. As already noted, this plan proposed the construction of two buildings, totalling 56 units.
[7]  The City asserted the following instances of noncompliance in its answer:

a. set-back requirements of the zoning code
b. parking requirements of the Americans with Disabilities Act
c. proper connection to existing sewer, water and street systems for the proper collection and conveyance of storm water runoff including:
i. a continuous easement for storm sewer
ii. no easement had been dedicated
iii. a portion of the planned storm sewer was improperly sized
iv. fail to provide for a required manhole
v. failed to provide sufficient inlets and inlet leads
d. insufficient detail was provided to determine if the plans required driveway approaches which conform to City standards.
[8]  The City's building inspector testified at his deposition that city ordinances required a twenty-foot setback on rear yards, and a fifteen-foot setback on side yards. The building depicted in Lake Bluffs plans had a five-foot stoop along one side of the structure. The building inspector further testified:

Q: Now, so in order to comply with the setback requirements, building one would have to move how far north in order to . . . give them the stoop that they have asked for on their plan and comply with the absolute minimum setback which is the . . . 15-foot side yard? How far north does that building have to go?
A: In excess of five feet.
Q: It has to go five feet just for the 15-foot, right?
A: Correct.
Q: And then an additional five foot for the stoop?
A: Correct.
Q: And how much room is there on the north of the plan between the north edge of the building and the lot line?
A: Eight feet two inches.
Q: So this building can't fit on the lot?
A: The way it is designed here, no, it can't.
