Twenty-nine protesters were arrested at Georgetown University yesterday after they refused to dismantle a shanty and leave a building they had occupied for two weeks in protest of the school's investments with companies that have financial interests in South Africa, officials said.

They said six other protesters who attempted to prevent police patrol wagons from leaving the university also were arrested.

University spokeswoman Anne Klass said 29 persons who had occupied the lobby of the White-Gravenor Building, which houses the undergraduate admissions office, a dean's office and classrooms, were arrested about 8:30 a.m. A spokesman for D.C. police said they were charged with unlawful entry.

Klass said the protesters, most of whom are students, had chained the front doors closed and occupied the lobby of the building since April 11, forcing others to use side entrances. Many of the protesters had to be carried from the building, she said.

The demonstrators, organized by the Student Coalition Against Apartheid and Racisim, were protesting South Africa's apartheid policy of racial segregation and were demanding total divestment of the university's $9 million worth of holdings in companies with financial interests in that country.

Klass said the university currently urges all companies in which it owns stock to sign and adhere to the Sullivan Principles, which outline social and economic measures aimed at increasing the rights of South African blacks.

Yesterday's arrest followed a rally Thursday night in which students constructed a shanty in front of the White-Gravenor building, Klass said. She said the students were warned by Dean of Student Affairs John DeGioia that the structure could stand only for the duration of the rally because "shanties have become a source of student confrontations on many campuses" and the school "could not provide sufficient protection" for students in and around the shanty.

Klass said the structure was not removed after Thursday's rally and was dismantled yesterday.

A few miles away at American University, a student and an official said yesterday that protesters there had agreed to dismantle four shanties that were built on Monday because university officials had agreed to meet with the students next Wednesday to discuss their demands, which include disclosure of the university's investment portfolio.

In January, students at Dartmouth College in Hanover, N.H., destroyed a symbolic shantytown with sledgehammers, throwing the university into an ideological uproar.

Meanwhile, 47 antiapartheid demonstrators at Yale University were arrested yesterday for blocking entrances to an administration building that houses the president's office, and on Thursday 11 student demonstrators were arrested at Boston University.