图1
对Make Assembly Com-Visible选项划钩。
设置项目的编译选项,如图2所示:
图2
图2中对Register for COM Interop选中,对COM组件进行注册。(注意,此处如果实在debug状态下修改的,那在调到release状态下还需要再设置一次。)
设置应用程序的AssemblyInfo属性,右击项目的Properties,打开AssemblyInfo文件,Assembly:AllowPartiallyTrustedCallers,注意添加引用System.Security,代码如下:
复制代码using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("CardReader.Controls")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("CardReader.Controls")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly:AllowPartiallyTrustedCallers()]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(true)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("15493d85-ec9e-4c75-a237-9009a997b780")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]










