使用Visual Studio 2008编译VC程序,如果窗体上需要引入一个C#编写的UserControl,那么必须在引入程序的代码*.h文件包含afxwinforms.h文件,比如:
[csharp]
#pragma once
#include <afxwinforms.h>
#using “..\Bin\MyUserControl.dll” // C# UserControl assembly
[/csharp]
包含afxwinforms.h必须选择“/clr”选项,即要选中Configuration Properties->General下的“Common Language Runtime Support (/clr)”。