Open source cad drawing (dwg) library in C#
The major hurdle with the DWG format is that the binary format changes every 3 years - and it is due to change again in March 2009. It is encrypted and the specifications for it are not made public. It is a massively complicated library with many dark alleys unknown to even AutoDesk (they acquired it years ago).
Not open source but the Open Design Alliance ... (from their Web site)...
is a non-profit membership-based consortium of software companies, developers and users committed to promoting the open exchange of CAD data now and in the future. In addition to setting standards for CAD data formats, the ODA also focuses on the practical matter of developing software libraries of exceptional quality that enable ODA members to develop applications capable of reading and writing the popular DWG and DGN CAD file formats.
Cost depends on what you are using the libraries for but the base-level cost for a developer is U$100/year with a U$250 joining fee. Compare that to AutoDesk's RealDWG at $2500/year and $5000 for the 1st year then it's a bargain. The RealDWG licence is per product, by the way. The ODA licenses are a bit more reasonable and also allow you to make more than 1 product on the same license. you can pay for the source code but it costs a bomb - less than developing it yourself though
If you only have 1 product then perhaps RealDWG will suit you but it's Windows only - bonus, it has a .NET API which the ODA are still working on ... the ODA's .NET APIs (there are 2) are well-established. The ODA products are compiled for a number of operating systems, including Windows (32-bit), SGI, Solaris, Windows (64-bit), Macintosh, HP, Windows CE, Linux, IBM AIX.
I any case that's a massive wheel to reinvent so it's definitely worth paying for one that already turns.
Some 3rd-party libraries exist out there with limited specific API functionality to try searching for those if your needs are very specific.
It is also worth noting that AutoDesk has been in more-or-less continuous litigation with the ODA for years now. If you decide to compete with them then that's another complexity you have to look forward to.
UPDATE:
Those days are pretty-much over.
I am also developing a product that talks to DWG files. I'm going the commercial route because the time, expense and hassle involved is utterly uneconomical for me.
UPDATE:
I did. tvCAD.tv is built on RealDwg
Update July 2018
Although I used RealDwg for tvCAD, I would probably use the ODA libraries if I were to start that project today. Building the RealDwg installer was a nightmare. Also, the RealDwg install size is about 10x the ODA install size. Yah, seriously.
Autodesk's dominance in the AutoCAD market is waning, it is no longer the "IBM" choice. I may convert tvCAD to the ODA libraries sometime in the future - it wouldn't take much more pain to push me into that. The licensing costs are comparable.
I have historically found the support from the ODA to be better than that in the Autodesk environment, apart from the active and fantastic peer support on the forums mentioned in the AutoCAD tag wiki which is pretty universal to all the platforms. .NET code from RealDwg can be used pretty-much verbatim with the ODA libraries. Ditto with .NET plugins for AutoCAD / BricsCAD etc.
If you go down the dxf route I would suggest netDXF . it's open source and worked well for my limited requirements though it is missing multi-line text support and the author says there are some other things he wont support because they're proprietary to autodesk.
There are no open source solutions, there are a few commercial ones, amongst which a .NET component named CadLib provided by Wout Ware: http://www.woutware.com/cadlib.html.