Muslims Have Least Sex Outside Marriage, Study Suggests

Muslims Have Least Sex Outside Marriage, Study Suggests
Date: 18 October 2012 Time: 12:52 PM ET


Muslims Have Least Sex Outside Marriage, Study Suggests

Muslims Have Least Sex Outside Marriage, Study Suggests
Date: 18 October 2012 Time: 12:52 PM ET


Obesity Causing Pathogen Discovered by Chinese Scientists

An opportunistic pathogen isolated from the gut of an obese human causes obesity in germfree mice

Na Fei1 and Liping Zhao1,2

  1. 1State Key Laboratory of Microbial Metabolism and School of Life Sciences and Biotechnology, Shanghai Jiao Tong University, Shanghai, China
  2. 2Shanghai Centre for Systems Biomedicine, Shanghai Jiao Tong University, Shanghai, China

Correspondence: L Zhao, State Key Laboratory of Systems Biomedicine, Shanghai Centre for Systems Biomedicine, Shanghai Jiao Tong University, Room 3-517, Biology Building, 800 Dongchuan Road, Minhang Campus, Shanghai 200240, China. E-mail:

Received 1 August 2012; Revised 24 October 2012; Accepted 28 October 2012
Advance online publication 13 December 2012



Lipopolysaccharide endotoxin is the only known bacterial product which, when subcutaneously infused into mice in its purified form, can induce obesity and insulin resistance via an inflammation-mediated pathway. Here we show that one endotoxin-producing bacterium isolated from a morbidly obese human’s gut induced obesity and insulin resistance in germfree mice. The endotoxin-producing Enterobacter decreased in relative abundance from 35% of the volunteer’s gut bacteria to non-detectable, during which time the volunteer lost 51.4kg of 174.8kg initial weight and recovered from hyperglycemia and hypertension after 23 weeks on a diet of whole grains, traditional Chinese medicinal foods and prebiotics. A decreased abundance of endotoxin biosynthetic genes in the gut of the volunteer was correlated with a decreased circulating endotoxin load and alleviated inflammation. Mono-association of germfree C57BL/6J mice with strain Enterobacter cloacae B29 isolated from the volunteer’s gut induced fully developed obesity and insulin resistance on a high-fat diet but not on normal chow diet, whereas the germfree control mice on a high-fat diet did not exhibit the same disease phenotypes. The Enterobacter-induced obese mice showed increased serum endotoxin load and aggravated inflammatory conditions. The obesity-inducing capacity of this human-derived endotoxin producer in gnotobiotic mice suggests that it may causatively contribute to the development of obesity in its human host.


gut microbiota; germfree mice; endotoxin-producing bacterium; obesity; insulin resistance; high-fat diet

The role of the gut microbiota in the pathogenesis of obesity has emerged into an important research area (Backhed et al., 2004). Gram-negative opportunistic pathogens in the gut may be pivotal in obesity (Schumann et al., 1990Zhang et al., 20102012). Lipopolysaccharide (LPS) endotoxin purified from Escherichia coliinduced obese and insulin-resistant phenotypes when subcutaneously infused into mice at a concentration comparable to what can be found in a mouse model of high-fat diet (HFD)-induced obesity (Cani et al., 2007). Endotoxin-induced inflammation seems to be essential for the development of obese and insulin-resistant phenotypes in the mouse model involving LPS infusion, as CD14-knockout mice did not develop these phenotypes after endotoxin infusion (Cani et al., 2007). Epidemiological studies show increased population of endotoxin producers and elevated endotoxin load in various obese cohorts (Lepper et al., 2007Ruiz et al., 2007Moreno-Navarrete et al., 2011), but experimental evidence of endotoxin producers having a causative role in human obesity is lacking.

During our clinical studies, we found that Enterobacter, a genus of opportunistic, endotoxin-producing pathogens (Sanders and Sanders, 1997), made up 35% of the gut bacteria in a morbidly obese volunteer (weight 174.8kg, body mass index 58.8kgm−2) suffering from diabetes, hypertension and other serious metabolic deteriorations (Table 1). The volunteer lost 30.1kg after 9 weeks, and 51.4kg after 23 weeks, on a diet composed of whole grains, traditional Chinese medicinal foods and prebiotics (WTP diet, Supplementary Information; Supplementary Figure 1), with continued amelioration of hyperinsulinemia, hyperglycemia and hypertension until most metabolic parameters improved to normal ranges (Table 1). After 9 weeks on the WTP diet, this Enterobacter population in the volunteer’s gut reduced to 1.8%, and became undetectable by the end of the 23-week trial, as shown in the clone library analysis (Table 1; Supplementary Figures 2 and 3). The serum–endotoxin load, measured as LPS-binding protein (Schumann et al., 1990), dropped markedly during weight loss, along with substantial improvement of inflammation, decreased level of interleukin-6 and increased adiponectin (Table 1). Metagenomic sequencing of the volunteer’s fecal samples at 0, 9 and 23 weeks on the WTP diet confirmed that during weight loss, the Enterobacteriaceae family was the most significantly reduced population (Supplementary Figure 4). The abundance of 25 KEGG Orthologies involved in the LPS biosynthetic pathway diminished considerably, together indicating a significant reduction of the endotoxin-producing capacity of the volunteer’s gut microbiota after the intervention (Supplementary Figures 5–7). In light of previous reports of the pivotal role that endotoxins have in metabolic diseases in mice (Cani et al., 2007), we hypothesized that this endotoxin-producing Enterobacter population may have a causative role in the metabolic deteriorations of its human host. To confirm the causative role it may have in obesity development, we confirm Koch’s postulate in an experimental host with an isolated strain of this Enterobacter population (Evans, 1976). We then obtained one clinical isolate (B29) from the volunteer’s fecal sample via a ‘sequence-guided isolation’ scheme (Rappé et al., 2002; Supplementary Figure 8), and identified it as Enterobacter cloacae through biochemical tests and 16S ribosomal RNA gene sequencing (Supplementary Table 1). We performed whole-genome sequencing on B29, and phylogenetic analysis using CVTree (Qi et al., 2004) and identified its nearest neighbor as E. cloacaesubsp. cloacae ATCC 13047 (Supplementary Information). A limulus amebocyte lysate test showed that B29 LPS has strong endotoxin activity (Supplementary Figure 9), and the draft genome sequence revealed LPS biosynthesis genes similar to those in the metagenome from the day 0 fecal sample (Supplementary Figure 10).

Previous studies show that germfree mice are resistant to HFD-induced obesity (Backhed et al., 2007Ding et al., 2010Rabot et al., 2010). To test whether B29 can overcome this resistance to obesity by colonizing the gut of germfree mice (Supplementary Figure 11), we inoculated 1010 cells of B29 every day for the first week into 6- to 10-week-old germfree C57BL/6J mice (n=7 per group) under either normal chow diet (NCD) or HFD. We observed a slight body weight reduction among the mice during the inoculation period (Supplementary Figures 11–14). One mouse in each group died during inoculation because of the translocation of B29 into various organs (Sanders and Sanders, 1997; Supplementary Table 2). After the first week, the HFD-fed gnotobiotic mice inoculated with B29 (HFD+B29) showed a steady weight gain until eventually reaching an obese state comparable to that of the HFD-fed conventional mice (n=8 per group; Figures1a–c; Supplementary Figures 14–17). The excessive fat accumulation in the HFD+B29 gnotobiotic mice was associated with an altered lipometabolism including a leptin-resistant phenotype, reduced expression of fasting-induced adipose factor in the ileum, and increased expression of acetyl-CoA carboxylase 1, fatty acid synthase and peroxisome proliferator-activated receptor-gamma genes in the liver (Supplementary Figures 18–19; Backhed et al., 20042007). The HFD+B29 gnotobiotic mice developed the most significant insulin-resistant phenotype as shown in the oral glucose tolerance test and 2h post load insulin levels at the end of the trial (Figures 1d and e). This group also had the greatest increases in liver and spleen weights and the greatest decrease in cecum weight (Supplementary Table 3). The NCD-fed mice inoculated with either B29 (NCD+B29) or Luria–Bertani (LB) medium (NCD+LB) both remained lean throughout the trial (Figures 1a–c). The HFD-fed germfree mice inoculated with LB (HFD+LB) experienced significant weight gain over the first 9 weeks but eventually became no different, based on the obesity parameters tested, from the NCD-fed groups by the end of the 16-week trial, except for a moderately increased epididymal fat pad and a low level of insulin resistance (Supplementary Figure 14; Figures 1b and d). Our repeat of the animal test with HFD-fed gnotobiotic mice mono-associated with B29 confirmed that a single endotoxin producer such as B29 can function in the capacity of the whole microbiota for inducing obese and insulin-resistant phenotypes (Supplementary Figure 20). Inoculating 6- to 10-week-old germfree mice (n=4–6 per group) with a strain of Bifidobacterium animals via alternation of NCD and HFD feeding did not induce the same obese phenotype (Supplementary Figure 21), suggesting that obesity cannot be induced by introducing any bacteria in the germfree mice under HFD feeding.

Figure 1.

Figure 1 - Unfortunately we are unable to provide accessible alternative text for this. If you require assistance to access this image, please contact or the author

Gnotobiotic mice mono-associated with E. cloacae B29 become obese and insulin resistant with increased endotoxin load and provoked systemic inflammation under HFD feeding (data collected at the end of 16 weeks after inoculation). (a) Body weight; (b) mass of epididymal, mesenteric, subcutaneous inguinal and retroperitoneal fat pad; (c) abdominal photographs; (d) oral glucose tolerance test (OGTT) and the areas under the curve (AUC) for the plasma glucose; (e) serum 2h post load insulin; (f) enzyme-linked immunosorbent assay (ELISA) analysis of serum LPS-binding protein (LBP); (g) serum amyloid A (SAA); and (h) adiponectin corrected for bodyweight. The two-way analysis of variance (ANOVA) revealed a significant effect of the diet (P<0.01), a significant effect of B29 (P<0.01) and a significant diet × B29 interaction effect (P<0.01) on body weight, mass of epididymal, mesenteric, subcutaneous inguinal and retroperitoneal fat pad, serum LBP; a significant effect of the diet (P<0.01) and a significant effect of B29 (P<0.01) on OGTT; a significant effect of B29 (P<0.05) on serum 2h post load insulin. Data are shown as means±s.e.m. (n=6). NS, no significant difference; *P<0.05; **P<0.01. Color code for animal groups: NCD+LB, blue slash; NCD+B29, blue; HFD+LB, red slash; HFD+B29, red. LB, Luria–Bertani medium.

Full figure and legend (325K)

A slightly increased endotoxin load can induce a low-grade, chronic inflammation as a driving force for insulin resistance and altered lipometabolism in mice (Hotamisligil et al., 1996Cani et al., 2007). The serum LPS-binding protein was significantly higher in the HFD+B29 gnotobiotic mice than in the NCD+B29 gnotobiotic mice (Figure 1f), despite the fact that B29 reached a significantly greater population size in the gut of the NCD-fed gnotobiotic mice (Supplementary Figure 13). As B29 was the only LPS producer in the gnotobiotic-mouse gut (Supplementary Figure 22), the increased serum–endotoxin load in the HFD+B29 gnotobiotic mice could only come from B29. As the gene expression levels of the two tight junction proteins occludin and ZO-1 (Cani et al., 2008) in the ileum were not significantly different among the groups (Supplementary Figure 23), the high amount of endotoxin translocation from the gut to the serum in the HFD+B29 gnotobiotic mice may be facilitated by chylomicrons induced by long-chain fatty acids in the HFD (Cani et al., 2007Ghoshal et al., 2009), rather than by impaired gut barrier function (Cani et al., 2007Zhang et al., 20102012). In accordance with the increased endotoxin load, the HFD+B29 gnotobiotic mice had the greatest increase in serum amyloid A protein levels and the greatest decrease in adiponectin secretion, suggesting that these mice had the greatest increase in systemic inflammation (Figures 1g and h). The expression of the tumor necrosis factor-alpha, interleukin-1β, interleukin-6, I kappa B kinase epsilon and Toll-like receptor 4 pro-inflammatory genes increased significantly in the liver and epididymal fat pad but not in the ileum of the HFD+B29 gnotobiotic mice (Supplementary Figure 24), indicating local inflammation induced in the former two tissues but not in the gut, in contrast to a previous report (Ding et al., 2010). The HFD+LB germfree mice had moderately higher levels of serum serum amyloid A and liver tumor necrosis factor-alpha expression than the NCD-fed groups, suggesting that the HFD induced some host inflammation (Tripathy et al., 2003), which is, however, much lower than that induced by B29. Taken together, our results suggest that endotoxin-induced inflammation may have a pivotal role in obesity induced by E. cloacae B29, supporting the existence of a putative chain of causation from endotoxin producers in the gut to the obesity end points.

Germfree mice have been extensively used for obesity studies. For example, Gordon et al. showed that co-inoculation of germfree mice with the plant polysaccharide-fermenting Bacteroides thetaiotaomicron and the methane-producing Methanobrevibacter smithii significantly increased the epididymal fat pad but not the total bodyweight (Samuel and Gordon, 2006). As a step forward, our study has followed a procedure modified from Koch’s Postulates (Evans, 1976) and, for the first time, established a gnotobiotic-mouse obesity model combining HFD with a human-originated endotoxin producer. This work suggests that the overgrowth of an endotoxin-producing gut bacterium is a contributing factor to, rather than a consequence of, the metabolic deteriorations in its human host. In fact, this strain B29 is probably not the only contributor to human obesity in vivo, and its relative contribution needs to be assessed. Nevertheless, by following the protocol established in this study, we hope to identify more such obesity-inducing bacteria from various human populations, gain a better understanding of the molecular mechanisms of their interactions with other members of the gut microbiota, diet and host for obesity, and develop new strategies for reducing the devastating epidemic of metabolic diseases.



  1. Backhed F, Ding H, Wang T, Hooper LV, Koh GY, Nagy A et al. (2004). The gut microbiota as an environmental factor that regulates fat storage. Proc Natl Acad Sci USA 101: 15718–15723. | Article | PubMed | CAS |
  2. Backhed F, Manchester JK, Semenkovich CF, Gordon JI. (2007). Mechanisms underlying the resistance to diet-induced obesity in germ-free mice. Proc Natl Acad Sci USA 104: 979–984. | Article | PubMed | CAS |
  3. Cani PD, Amar J, Iglesias MA, Poggi M, Knauf C, Bastelica D et al. (2007). Metabolic endotoxemia initiates obesity and insulin resistance. Diabetes 56: 1761–1772. | Article | PubMed | ISI | CAS |
  4. Cani PD, Bibiloni R, Knauf C, Waget A, Neyrinck AM, Delzenne NM et al. (2008). Changes in gut microbiota control metabolic endotoxemia-induced inflammation in high-fat diet-induced obesity and diabetes in mice. Diabetes57: 1470–1481. | Article | PubMed | ISI | CAS |
  5. Ding S, Chi MM, Scull BP, Rigby R, Schwerbrock NM, Magness S et al. (2010). High-fat diet: bacteria interactions promote intestinal inflammation which precedes and correlates with obesity and insulin resistance in mouse.PLoS One 5: e12191. | Article | PubMed | CAS |
  6. Evans AS. (1976). Causation and disease: the Henle-Koch postulates revisited. Yale J Biol Med 49: 175–195. | PubMed | ISI | CAS |
  7. Ghoshal SJ, Witta J, Zhong J, de Villiers W, Eckhardt E. (2009). Chylomicrons promote intestinal absorption of lipopolysaccharides. J Lipid Res 50: 90–97. | Article | PubMed | ISI | CAS |
  8. Hotamisligil GS, Peraldi P, Budavari A, Ellis R, White MF, Spiegelman BM et al. (1996). IRS-1-mediated inhibition of insulin receptor tyrosine kinase activity in TNF-alpha- and obesity-induced insulin resistance. Science 271: 665–668. | Article | PubMed | ISI | CAS |
  9. Lepper PM, Schumann C, Triantafilou K, Rasche FM, Schuster T, Frank H et al. (2007). Association of lipopolysaccharide-binding protein and coronary artery disease in men. J Am Coll Cardiol 50: 25–31. | Article | PubMed | ISI |
  10. Moreno-Navarrete JM, Ortega F, Serino M, Luche E, Waget A, Pardo G et al. (2011). Circulating lipopolysaccharide-binding protein (LBP) as a marker of obesity-related insulin resistance. Int J Obes (Lond) 36: 1442–1449. | Article | PubMed |
  11. Qi J, Luo H, Hao B. (2004). CVTree: a phylogenetic tree reconstruction tool based on whole genomes. Nucleic Acids Res 32: 45–47. | Article | PubMed |
  12. Rabot S, Membrez M, Bruneau A, Gerard P, Harach T, Moser M et al. (2010). Germ-free C57BL/6J mice are resistant to high-fat-diet-induced insulin resistance and have altered cholesterol metabolism. FASEB J 24: 4948–4959. | Article | PubMed | ISI | CAS |
  13. Rappé MS, Connon SA, Vergin KL, Giovannoni SJ. (2002). Cultivation of the ubiquitous SAR 11 marine bacterioplankton clade. Nature 418: 630–633. | Article | PubMed | ISI | CAS |
  14. Ruiz AG, Casafont F, Crespo J, Cayon A, Mayorga M, Estebanez A et al. (2007). Lipopolysaccharide-binding protein plasma levels and liver TNF-alpha gene expression in obese patients: evidence for the potential role of endotoxin in the pathogenesis of non-alcoholic steatohepatitis. Obes Surg17: 1374–1380. | Article | PubMed |
  15. Samuel BS, Gordon JI. (2006). A humanized gnotobiotic mouse model of host-archaeal-bacterial mutualism. Proc Natl Acad Sci USA 103: 10011–10016. | Article | PubMed | CAS |
  16. Sanders J. WE, Sanders CC. (1997). Enterobacter spp.: pathogens poised to flourish at the turn of the century. Clin Microbiol Rev 10: 220–241. | PubMed |
  17. Schumann RR, Leong SR, Flaggs GW, Gray PW, Wright SD, Mathison JC et al. (1990). Structure and function of lipopolysaccharide binding protein.Science 249: 1429–1431. | Article | PubMed | ISI | CAS |
  18. Tripathy D, Mohanty P, Dhindsa S, Syed T, Ghanim H, Aljada A et al. (2003). Elevation of free fatty acids induces inflammation and impairs vascular reactivity in healthy subjects. Diabetes 52: 2882–2887. | Article | PubMed | ISI | CAS |
  19. Zhang C, Zhao Y, Zhang M, Pang X, Wang L, Zhao L. (2012). Structural resilience of the gut microbiota in adult mice under high-fat dietary perturbations. ISME J 6: 1848–1857. | Article | PubMed |
  20. Zhang C, Zhang M, Wang S, Han R, Cao Y, Hua W et al. (2010). Interactions between gut microbiota, host genetics and diet relevant to development of metabolic syndromes in mice. ISME J 4: 232–241. | Article | PubMed | ISI | CAS |


We appreciate Professor R. Losick, L Neuhauser, M Obin and M Pop for critical reading of the manuscript and kind suggestions. We are also grateful to the following individuals for their kind assistance during the study: S Xiao, J Shen, X Pang, M Zhang, XJ Zhang, Y Zhao, L Wang, J Wang, Y Zhang, G Wu, G Wang, H Ou, J Qi, JJ Wang, X Zhang, R Wang, M Song, J Xu, H Tang, T Liu, Q Zhang, N Zhao, C Zhang, Y Fan, S Liu, YZ Fan, T Wang, Z Hu, R Xi, XY Zhang, C Liu, H Wu, X Guo, X Li, G Ning, S Yang and G Zhao.

This work was supported by Project 30730005 of the National Nature Science Foundation of China (NSFC), 863 Projects 2008AA02Z315 and 2009AA02Z310, Key Projects 2007DFC30450 and 075407001 of International Cooperation Program Grants and Project in the National Science and Technology Pillar Program 2006BAI11B08.

Supplementary Information accompanies the paper on The ISME Journal website

This work is licensed under the Creative Commons Attribution-NonCommercial-No Derivative Works 3.0 Unported License. To view a copy of this license, visit

Microsoft Blocks Linux from running on Windows 8 PCs

Microsoft to stop Linux, older Windows, from running on Windows 8 PCs | ZDNet

Summary: It doesn’t take much reading between the lines to see that Microsoft is going to try to keep Linux, older versions of Windows, and other operating systems off Windows 8 PCs.
Steven J. Vaughan-Nichols

By Steven J. Vaughan-Nichols for Linux and Open Source | September 23, 2011 — 07:55 GMT (00:55 PDT)

[The Microsoft Death Star is back in orbit and firing.] Thanks to Mary Jo Foley, we now know that in the name of “security,” Microsoft will be trying to use UEFI (Unified Extensible Firmware Interface) to block Linux, older versions of Windows, and other alternative operating systems from booting on Windows 8 PCs. Thanks Microsoft we appreciate it.

In a new Microsoft blog, Building Windows 8, by Steven Sinofsky, Microsoft’s president of the Windows division, Linux isn’t mentioned, and he tries to place the blame on the UEFI security protocol. Behind all his dodging, the facts are that Microsoft UEFI secure boot is requirement for Windows 8 certification and that, while “OEMs [original equipment manufacturers) are free to choose how to enable this support,” they still have to have it. In turn, that will make it harder for OEMs to support alternative operating systems and, if the OEM does bow down to Microsoft’s demands, it will make it almost impossible for end-users to run Linux, older versions of Windows, or other alternative operating systems on Windows 8 certified PCs.

In short, if Microsoft has its way, all Windows 8 PCs will be even more locked into their pre-installed operating systems than Macs are into Mac OS X. Indeed, a better comparison would be how phone companies lock you into their smartphone operating systems. Just like them the Windows 8 PC you buy in 2013 will be permanently locked into Windows 8. And, like smartphones, only expert firmware hackers will be able to switch out operating systems or even enable dual-booting operating systems.

This isn’t the first time Microsoft has tried to lock out competitors from Windows PCs. In the early 2000s, Microsoft tried to combine Windows and the BIOS with a Digital Right Management (DRM) scheme called Next Generation Secure Computing Base (NGSCB), AKA Palladium. At the time, the point wasn’t so much as to block operating systems as it was to build DRM into PCs so you couldn’t play any music or video content unless you had a license for it. That effort failed.

That isn’t stopping Microsoft from once more trying to stop you from using your computer the way you want to use it though.

Matthew Garrett, the Red Hat engineer who first spotted Microsoft’s new sneak attack on alternative operating systems, has taken a new look at Microsoft’s latest announcements and Garrett and Red Hat after “discussing the problem with other Linux vendors, hardware vendors and BIOS vendors [to make] sure that we understood the ramifications of the policy in order to avoid saying anything that wasn’t backed up by facts. These are the facts:”

Windows 8 certification requires that hardware ship with UEFI secure boot enabled.
Windows 8 certification does not require that the user be able to disable UEFI secure boot, and we’ve already been informed by hardware vendors that some hardware will not have this option.
Windows 8 certification does not require that the system ship with any keys other than Microsoft’s.
A system that ships with UEFI secure boot enabled and only includes Microsoft’s signing keys will only securely boot Microsoft operating systems.

Garrett explains that this is a problem “Because there’s no central certification authority for UEFI signing keys. Microsoft can require that hardware vendors include their keys. Their competition can’t. A system that ships with Microsoft’s signing keys and no others will be unable to perform secure boot of any operating system other than Microsoft’s. No other vendor has the same position of power over the hardware vendors. Red Hat is unable to ensure that every OEM carries their signing key. Nor is Canonical. Nor is Nvidia, or AMD or any other PC component manufacturer. Microsoft’s influence here is greater than even Intel’s.”

Indeed Microsoft still owns the desktop market. Macs still have less than 5% of the world desktop market according to Gartner and the Linux desktop has proven to be a non-starter, PC vendors will have little choice but to kowtow to Microsoft’s Windows 8 demands.

“What does this mean for the end user?” continued Garrett. “Microsoft claims that the customer is in control of their PC. That’s true, if by ‘customer’ they mean ‘hardware manufacturer.’ The end user is not guaranteed the ability to install extra signing keys in order to securely boot the operating system of their choice. The end user is not guaranteed the ability to disable this functionality. The end user is not guaranteed that their system will include the signing keys that would be required for them to swap their graphics card for one from another vendor, or replace their network card and still be able to netboot, or install a newer SATA controller and have it recognize their hard drive in the firmware. The end user is no longer in control of their PC.”

Garrett concluded, “So, the truth is that Microsoft’s move removes control from the end user and places it in the hands of Microsoft and the hardware vendors. The truth is that it makes it more difficult to run anything other than Windows. The truth is that UEFI secure boot is a valuable and worthwhile feature that Microsoft [is] misusing to gain tighter control over the market. And the truth is that Microsoft [hasn’t] even attempted to argue otherwise.”

Garrett is, understandably, most concerned about how this will effect desktop Linux. I wonder though if what Microsoft really wants is to avoid a repeat of the Vista fiasco by making sure OEMs and end-users can’t go back to Windows 7 or XP. As Windows 7’s slow adoption and Vista’s flop has shown, users really haven’t been that interested in moving off Windows XP. Since Windows 8’s Metro interface adds an entirely new level of complications for both independent software vendors (ISV)s and end-users, I can see why Sinofsky would want to force Windows 8 down the throats of Windows users “for their own good.”

So what does it all boil down to? As it stands now Microsoft is saying OEMs don’t have to do it. They just have to do it if they want to sell PCs with Windows on them. Paging the anti-trust lawyers, I think Microsoft’s latest attempt to abuse their PC monopoly power bears investigation. Welcome back Evil Empire, I knew you couldn’t really be that far away.

AutoCAD with .NET 2

Lesson 2: Getting to Know your Development Environment

the previous lesson, you saw how you can increase productivity in
AutoCAD by implementing a plug-in built from a small amount of Visual
Basic .NET code.

.NET (or
the .NET Framework) is a technology created by Microsoft that enables
programmers to create and extend software applications. A programmer may
use the ,NET Framework to create a new software application from
scratch, to implement communication or interoperability between two
software applications, or to extend a software application by
implementing a plug-in for it (as you are doing here for AutoCAD). If
you are interested in learning more, you will find information in the Additional Topics section.

You will now look more closely at what happened when you built and executed the code in the previous lesson.

Provide Feedback: Please provide feedback about this AutoCADTraining or this lesson via email:

What does it mean to “build” code?

The code you typed into Visual Basic Express in Lesson 1 was a set of human-readable instructions (source
code) that needed to be converted into code that could be understood
and executed by the computer. The “build” you performed did just that:
it packaged up the resulting executable code into a DLL (Dynamic-Link Library) that can be loaded into AutoCAD.

following screenshot shows the output in DLL form along with the
associated program debug database (which provides additional information
when troubleshooting the DLL) that you built using Visual Basic Express
in Lesson 1. The path to where the DLL gets compiled is specified in
the Visual Basic Express project settings and is set, by default, to the
bin\Release or bin\Debug sub-folder of the Visual Basic Express project
folder (depending if you’re building a Release or Debug version of your
DLL – we’ll talk about that later).

Choosing a Programming Language and Development Tool

as humans use different languages to communicate, you have various
language options available to you when creating an AutoCAD plug-in:  for
the purposes of this guide we have chosen Visual Basic .NET, a strong
general-purpose programming language. Visual Basic .NET is particularly
popular with people learning to program, because the language syntax is
more easily readable than many other languages (such as C# or C++).

are a number of tools available for developing Visual Basic .NET code.
They range from open source tools such as SharpDevelop and MonoDevelop
to Microsoft’s flagship, professional development environment, Visual
Studio. This tutorial assumes you’re using Visual Basic Express, a free
version of Visual Studio for building Visual Basic .NET applications.

Visual Basic Express is an Integrated Development Environment (IDE) because it is composed of various tools, menus and toolbars which ease the creation and management of your code.

The project system in Visual Basic Express comprises Solution and Project files as well as Project Items,
the individual files belonging to projects. A solution is a container
for one or more projects. Each project can in turn be considered a
container for project items – such as source files, icons, etc. – most
of which get compiled into the resultant executable file (EXE or DLL).
Visual Basic Express provides a Solution Explorer that organizes and
displays the contents of the loaded solution in a tree-view format:

Visual Basic Express interface also contains a text editor and
interface designer. These are displayed in the main window depending on
the type of file being edited. The text editor is where you will enter
the Visual Basic .NET code for your AutoCAD plug-in. This editor
provides advanced features such as IntelliSense and collapsible code
sections along with the more classic text-editing features such as
bookmarks and the display of line numbers.

is an extremely valuable feature of the Visual Studio family that
greatly improves programmer productivity: it automatically provides
suggestions for the code being written based on the objects available
and the letters that are being typed. You will have already seen IntelliSense at work if you typed in the code in Lesson 1. That is one reason we suggested you didn’t copy and paste.

one of the key features of Visual Basic Express is its ability to build
Visual Basic .NET code into an executable file. During the build
process, the language compiler performs various checks and analyses on
the code. One such check is to ensure the code conforms to the
syntactical rules of the Visual Basic .NET language. The compiler also
performs various other checks, such as whether a variable has been
appropriately defined or not. Detected errors are reported via the Error
List window, typically found at the bottom of the main window. If you
made a mistake typing in the code in lesson 1, you may already have seen
this when you tried to build your plug-in.

Reviewing your use of Visual Basic Express

this section, you will review the steps performed using Visual Basic
Express from the previous lesson. However, we will put them in the
context of what you have just learned about programming in general and
building your code.

  1. In the first step, you simply launched Visual Basic Express.
  2. You then created a new Visual Basic .NET project of type AutoCAD plug-in. This project template was added when you installed the AutoCAD .NET Wizards.

    the development language used for this guide is Visual Basic .NET, you
    are working with Visual Basic Express, and therefore you see Visual Basic under the Installed Templates portion of the New Project dialog. The AutoCAD plug-in template is essentially a Class Library template, but with some additional settings.

    the middle section of this dialog, you saw various types of
    applications that can be created; you select the template according to
    the type of application you wish to create.

    The name you entered at the bottom of the dialog is used to identify the project within the solution.

  3. Your
    blank project was created, containing a few standard project references
    to core .NET components along with references to the two files that
    define the AutoCAD API (AcMgd.dll and AcDbMgd.dll). The project also
    includes two Visual Basic .NET class files (MyCommands.vb and MyPlugin.vb – you may have optionally deleted the MyPlugin.vb
    file from the project because it’s not needed for this tutorial). These
    files contained some simple boilerplate code. Clicking on one of those
    files in Solution Explorer displays the code it contains in the text
    editor window.
  4. You looked at the References section of the ‘My Project’ project settings and checked that AcDbMgd.dll and AcMgd.dll were correctly referenced (and AcCoreMdg.dll for AutoCAD 2013 and higher).
  5. Saving
    the solution created physical files representing the contents of your
    project on the computer’s hard drive, allowing you to open and edit it
    at another time in the future. You closed and reopened the project to
    ensure Visual Basic Express had correctly parsed the project files.
  6. AcMgd.dll and AcDbMgd.dll
    contain definitions of the AutoCAD APIs you will most commonly use in
    your plug-ins. You will always reference these two files in your AutoCAD
    plug-in projects. You will sometimes reference others too.
    • AcMgd.dll contains the APIs for controlling the AutoCAD application itself – defining custom commands
      opening and closing documents, plotting, etc.
    • AcDbMgd.dll contains the APIs for creating, editing or querying the contents of a DWG file.
    • From
      AutoCAD 2013, the APIs in AcMdg.dll were split between AcMgd.dll and
      AcCoreMgd.dll. AcCoreMgd.dll contains APIs related to the AutoCAD
      application login (such as selections set, comamnds and keywords), and
      AcMgd.dll contains ‘User Interface’ related APIs (such as dialogs).

    you created your AutoCAD plug-in project, the AutoCAD .NET Wizard
    Configurator dialog had these selected by default (you can’t unselect
    them). There were options to include other API definition files that we

  7. Next you added Visual Basic .NET code using the
    AutoCAD API into your project. In other words providing AutoCAD with
    instructions on how to modify how a block attribute behaves when it is

While developing code, it’s a good idea to build
the solution from time to time, to check whether errors have been
introduced in the code. The code does not necessarily have to be
complete or functional when building the solution. This approach can
help avoid potentially lengthy troubleshooting once the code is
complete, and has the side benefit of automatically saving any edited
source files before the build starts.

To build a solution inside Visual Basic Express, select Build Solution from the Debug pull-down menu.

If the build process was successful, you would see a Build Succeeded
status in the bottom left corner of the Visual Basic Express
application frame. If there was an error in your code, Visual Basic
Express will display an error list explaining the errors it has found.
It will also underline the error in your code in blue.  Here’s an
example where we deliberately added a mistake to the code you typed in
lesson one:

this lesson you took a brief look at what happens when you build a
project, as well as some background information on Visual Basic .NET and
Visual Basic Express. You reviewed the steps you had taken in the
previous lesson to build your basic AutoCAD plug-in, putting it in the
context of what you have learned about programming.

Additional Topics

Visual Basic Express vs. Visual Studio Professional

this guide, you are using Visual Basic Express. This is a free version
of Visual Studio and so it’s a great tool to start learning with.
Microsoft has targeted the Express editions of Visual Studio at
students, hobbyists and other part-time programmers. While it provides
most of the features of Visual Studio Professional, such as
IntelliSense, it does have certain limitations. For instance, it
contains fewer project templates and has limited options for debugging
and troubleshooting your code. If you are serious about plug-in
development beyond this introductory guide – and particularly if you
want to start developing commercial plug-ins – we recommend investing in
one of the more fully-featured members of the Visual Studio product

*There are several ‘professional’ versions of Visual Studio. Visit the Microsoft Visual Studio website for more information.

What is .NET?

remainder of this lesson includes quite a bit of technical jargon.
Don’t worry if you don’t completely understand it all when you first
read it. It will make more sense once you’ve become more familiar with
.NET after writing a few of your own plug-ins.

.NET Framework is a software framework that sits on top of the
Microsoft® Windows® operating system* and provides the underlying
platform, libraries and services for all .NET applications. The services
include memory management, garbage collection, common type system,
class libraries, etc.

* Subsets of .NET are also available on
other operating systems, whether via the open source Mono project or via
Microsoft® Silverlight®, but these are not topics for this guide. You
will focus solely on using.NET on Microsoft Windows.

What does the .NET Framework Contain?

The framework contains two main components:

  1. Common Language Runtime (CLR)This
    is the agent (or execution engine) in the .NET Framework responsible
    for managing the execution of code. Which is why code written to target
    this runtime is also known as managed code. All managed code runs under
    the supervision of the CLR, but what does this mean? The CLR manages
    code by providing core services such as memory management (which
    includes automatically releasing the computer’s memory for reuse on
    other tasks when it is no longer needed), error (or exception) handling,
    managing the use of multiple threads of execution and ensuring rules
    around the use of different types of object are adhered to. The CLR is
    really the foundation of the .NET Framework.
  2. .NET Framework Class LibraryAs
    the name suggests, this is a library or collection of object types that
    can be used from your own code when developing .NET applications. These
    .NET applications are targeted for Windows (whether command-prompt
    based or with a graphical user interface), the web or mobile devices.
    This library is available to all languages using the .NET Framework.

mentioned above, the CLR improves code robustness by making sure the
executing code conforms to a common type system (CTS). The CTS ensures
that all .NET (or managed) code – irrespective of the language – uses a
similar set of object types and can work together in the same
environment. It is this feature that makes it possible for you to write
applications in the development language of your choice and yet make use
of components/code written by programmers using other .NET languages.

Building Executables

you built your code into an EXE, it was compiled into Common
Intermediate Language (CIL – also known as MSIL) code using the
language-specific compiler. CIL is a CPU-independent set of instruction
that can be executed by the CLR on Windows operating systems. CIL is
typically portable across 32- and 64-bit systems and even – to some
extent – to non-Windows operating systems. The CIL code generated from
your VB source code was then packaged into a .NET assembly. Such an
assembly is a library of CIL code stored in Portable Executable (PE)
format (which contains both the CIL and its associated metadata).
Assemblies can either be process assemblies (EXEs) or library assemblies

During the course of this
guide, you will focus on developing a particular type of AutoCAD
plug-in: a process assembly (EXE) which communicates with AutoCAD.
Because of the overhead associated with developing them, you will not
spend time looking at AutoCAD AddIns, which are usually library
assemblies (DLLs) that get loaded into and executed within the memory
space of AutoCAD. One reason that implementing an EXE to work with
AutoCAD is simpler than developing an AddIn is related to its user
interface: Executables do not need to integrate seamlessly with the
AutoCAD user interface by adding ribbon buttons (for instance).

Running Executables

execution of a .NET assembly, CIL (residing in the assembly) is passed
through the CLR’s just-in-time (JIT) compiler to generate native (or
machine) code. JIT compilation of the CIL to native code occurs when the
application is executed. As not all of the code is required during
execution, the JIT compiler only converts the CIL when it is needed,
thus saving time and memory. It also stores any generated code in
memory, making it available for subsequent use without the need to

In the last step of this process, the native code gets executed by the computer’s processor.

If you would like more details on the process of building .NET applications, please refer to the MSDN Library