USinternetworking Inc., an Annapolis company that installs and manages business software for companies, has agreed to buy a smaller, private Fremont, Calif., company in a cash-and-stock deal that USi says is worth between $40 million and $50 million.

The acquisition of Appshop Inc., which USi said it would announce today, will add $23 million a year in revenue and boost its 105 customers by 40, said Andrew A. Stern, chairman and chief executive of USi. The deal is expected to close in about two months.

"This is an industry that's seeing some consolidation, and we want to be a consolidator," Stern said. Combined, the companies will have greater resources to spend on marketing, he said.

Appshop, which installs various Oracle Corp. applications for customers, employs 190 people, most of whom will remain, Stern said. USi employs 365.

USi will pay $5 million in cash and exchange 22.7 percent of the privately held USi's stock for Appshop. Bain Capital LLC owns 82 percent of USi, and another venture capital firm, Grotech Capital Group Inc., owns about 12 percent. One of Appshop's investors, 3i Group PLC, will appoint a new member to USi's board.

USi was a rising technology star in Annapolis, expanding quickly in the late 1990s, but in 2000 it ran into trouble, filing for bankruptcy protection in 2001. It emerged from Chapter 11 protection in May 2002 with far less debt but is still not profitable. The company is trying to pay off its remaining $24 million in debt and generate a profit by the end of the year, Stern said.