I am working on converting a very large project from VS2003/.NET 1.1 to VS2005/.NET 2.0. Our UI code is all C#, and we have managed C++ wrappers around some regular C++ to interface with our server. I have managed to get everything compiling and running OK, but I am having a big problem opening the designer for some of our forms.

When opening a problem form (which can actually be any form in the project, I am not sure why dome are OK sometime and not others), VS2005 starts chewing up tons of memory and using about 5-10% CPU. I took at look at it open files with process explorer, and noticed many many instances of our managed C++ shims all in C:\Documents and Settings\<my username>\Local Settings\Application Data\Microsoft\VisualStudio\8.0\ProjectAssemblies\<some random characters>. VS seems to be copying more and more of the managed shims to new subdirectories until it eventually runs out of memory.

I am not executing any code (other than InitializeComponent) in my constructor or OnLoad override (the code there is wrapped with if (!DesignMode)).

What the heck is VS doing Why is it shadow-copying the same assemblies over and over again

Josh Goldshlag

Re: Visual C# General Infinite loop loading referenced assemblies in designer


OK, I figured out some of what is going on. The problem is that the unmanaged dlls referenced by the managed ones are not on the PATH, and when VS2005 moves the managed dll to the ProjectAssemblies directory it cannot find the required unmanaged dll. Does anyone know of any way to either turn off the shadow copying or to have it copy the required unmanaged dlls as well


Re: Visual C# General Infinite loop loading referenced assemblies in designer


We had an identical error.

After opening an incident with Microsoft (and burning about 2 weeks), it was confirmed by Microsoft that the Windows Form Designer is not capable of displaying mixed C++ (managed and unmanaged) code from within a project that is compiled as an executable.

The project that is compiled into an executable must be clr : pure if you want to use the Form Designer. Thus it can't contain any unmanaged code.

If you want to use unmanaged code within a project that contains Windows Forms that you need to design within the Form Designer, then they need to compiled into a separate DLL. That project should be declared / clr.

Since the compiler option clr : pure was added in the upgrade from VS2003 to VS2005, this is a new restriction. Microsoft didn't document this change, however. (We also have this in writing from MS).

We didn't have any problems viewing forms that contained unmanaged code for quite a long time (over a year). Then things suddently stopped displaying in the Form Designer. Microsoft said that some "threshold" must have been reached, but couldn't elaborate on why things worked for so long before "breaking".

Good luck using managed and unmanaged code in conjunction with the form designer. "It just works" seems to be a marketing slogan rather than technical design criteria.