查看: 570|回复: 3

[文章教程] 有关COM Interop(COM互操作技术)的介绍

[复制链接]
xuanxiao 发表于 2022-11-12 10:53:21 | 显示全部楼层 |阅读模式
COM Interop 是一种让 .NET Framework 的程序能够和 COM 的程序相互操作的一种桥接技术,是 .NET Framework 互通性的一环,COM Interop 可以让 .NET Framework 的程序使用 COM 组件,也可以让 COM 程序使用 .NET Framework 的组件,例如可以使用 .NET Framework 开发应用程序给 ASP 的应用程序使用,或是把旧有的 ActiveX 组件让 .NET Framework 的程序调用。

COM Interop 的服务是由 System.Runtime.InteropServices 名字空间中的类别来提供,其中最重要的是 Marshal 类别,它提供了 managed code 和 unmanaged code 之间的资料格式与指针转换,对于互通性来说具有相当大的帮助。

在 .NET Framework SDK 中提供了可由 COM 类型库中产生 .NET 组件 的 tlbimp.exe,以及让 .NET 组件产生类型库的regasm.exe两个工具程序。


组件对象模型 (COM) 允许对象向其他组件和宿主应用程序公开其功能。虽然 COM 对象多年来一直是 Windows 编程的基础,但为公共语言运行时 (CLR) 设计的应用程序具有许多优点。

.NET Framework 应用程序最终将取代那些使用 COM 开发的应用程序。在此之前,您可能必须使用 Visual Studio 使用或创建 COM 对象。与 COM 或 COM互操作的互操作性使您能够使用现有的 COM 对象,同时按照自己的节奏过渡到 .NET Framework。

打开我们的注册表,定位到HKEY_CLASSES_ROOT,然后你就会发现有大量的.NET类的ProgId和CLSID,这样我们就可以通过这些特征信息来创建并使用这些对象。
1181112654.png
 楼主| xuanxiao 发表于 2023-3-28 22:31:50 | 显示全部楼层
VBScript/WSH可以使用的.NET组件列表 :

System.AccessViolationException System.AppDomainManager System.AppDomainSetup System.AppDomainUnloadedException System.ApplicationException System.ArgumentException System.ArgumentNullException System.ArgumentOutOfRangeException System.ArithmeticException System.ArrayTypeMismatchException System.BadImageFormatException System.CannotUnloadAppDomainException System.Collections.ArrayList System.Collections.CaseInsensitiveComparer System.Collections.CaseInsensitiveHashCodeProvider System.Collections.Generic.KeyNotFoundException System.Collections.Hashtable System.Collections.Queue System.Collections.SortedList System.Collections.Stack System.ContextMarshalException System.ContextStaticAttribute System.Data.SqlClient.SQLDebugging System.DataMisalignedException System.Diagnostics.Debugger System.Diagnostics.StackFrame System.Diagnostics.StackTrace System.Diagnostics.SymbolStore.SymDocumentType System.Diagnostics.SymbolStore.SymLanguageType System.Diagnostics.SymbolStore.SymLanguageVendor System.DivideByZeroException System.DllNotFoundException System.DuplicateWaitObjectException System.EnterpriseServices.CompensatingResourceManager.ClerkMonitor System.EnterpriseServices.CompensatingResourceManager.Compensator System.EnterpriseServices.Internal.AppDomainHelper System.EnterpriseServices.Internal.AssemblyLocator System.EnterpriseServices.Internal.ClientRemotingConfig System.EnterpriseServices.Internal.ClrObjectFactory System.EnterpriseServices.Internal.ComManagedImportUtil System.EnterpriseServices.Internal.ComSoapPublishError System.EnterpriseServices.Internal.GenerateMetadata System.EnterpriseServices.Internal.IISVirtualRoot System.EnterpriseServices.Internal.Publish System.EnterpriseServices.Internal.ServerWebConfig System.EnterpriseServices.Internal.SoapClientImport System.EnterpriseServices.Internal.SoapServerTlb System.EnterpriseServices.Internal.SoapServerVRoot System.EnterpriseServices.Internal.SoapUtility System.EnterpriseServices.RegistrationConfig System.EnterpriseServices.RegistrationHelper System.EntryPointNotFoundException System.EventArgs System.Exception
 楼主| xuanxiao 发表于 2023-3-28 22:32:03 | 显示全部楼层
System.ExecutionEngineException System.FieldAccessException System.FlagsAttribute System.FormatException System.Globalization.DateTimeFormatInfo System.Globalization.GregorianCalendar System.Globalization.HebrewCalendar System.Globalization.HijriCalendar System.Globalization.JapaneseCalendar System.Globalization.JulianCalendar System.Globalization.KoreanCalendar System.Globalization.NumberFormatInfo System.Globalization.StringInfo System.Globalization.TaiwanCalendar System.Globalization.ThaiBuddhistCalendar System.IndexOutOfRangeException System.InvalidCastException System.InvalidOperationException System.InvalidProgramException System.IO.DirectoryNotFoundException System.IO.DriveNotFoundException System.IO.EndOfStreamException System.IO.FileLoadException System.IO.FileNotFoundException System.IO.IOException System.IO.IsolatedStorage.IsolatedStorageException System.IO.MemoryStream System.IO.PathTooLongException System.IO.StringWriter System.MemberAccessException System.MethodAccessException System.MissingFieldException System.MissingMemberException System.MissingMethodException System.MTAThreadAttribute System.MulticastNotSupportedException System.NonSerializedAttribute System.NotFiniteNumberException System.NotImplementedException System.NotSupportedException System.NullReferenceException System.Object System.ObsoleteAttribute System.OperationCanceledException System.OutOfMemoryException System.OverflowException System.ParamArrayAttribute System.PlatformNotSupportedException System.Random System.RankException System.Reflection.AmbiguousMatchException System.Reflection.AssemblyName System.Reflection.CustomAttributeFormatException System.Reflection.InvalidFilterCriteriaException System.Reflection.ObfuscationAttribute System.Reflection.TargetException System.Reflection.TargetParameterCountException System.Resources.MissingManifestResourceException System.Resources.MissingSatelliteAssemblyException System.Runtime.CompilerServices.CallConvCdecl System.Runtime.CompilerServices.CallConvFastcall System.Runtime.CompilerServices.CallConvStdcall System.Runtime.CompilerServices.CallConvThiscall System.Runtime.CompilerServices.CompilerGlobalScopeAttribute System.Runtime.CompilerServices.DiscardableAttribute System.Runtime.CompilerServices.IDispatchConstantAttribute System.Runtime.CompilerServices.IUnknownConstantAttribute System.Runtime.CompilerServices.MethodImplAttribute System.Runtime.CompilerServices.NativeCppClassAttribute System.Runtime.Hosting.ApplicationActivator System.Runtime.InteropServices.ComConversionLossAttribute System.Runtime.InteropServices.COMException System.Runtime.InteropServices.ComImportAttribute System.Runtime.InteropServices.ComRegisterFunctionAttribute System.Runtime.InteropServices.ComUnregisterFunctionAttribute System.Runtime.InteropServices.ExternalException System.Runtime.InteropServices.InAttribute System.Runtime.InteropServices.InvalidComObjectException System.Runtime.InteropServices.InvalidOleVariantTypeException System.Runtime.InteropServices.MarshalDirectiveException System.Runtime.InteropServices.OptionalAttribute System.Runtime.InteropServices.OutAttribute System.Runtime.InteropServices.PreserveSigAttribute System.Runtime.InteropServices.RegistrationServices System.Runtime.InteropServices.RuntimeEnvironment System.Runtime.InteropServices.SafeArrayRankMismatchException System.Runtime.InteropServices.SafeArrayTypeMismatchException System.Runtime.InteropServices.SEHException System.Runtime.InteropServices.SetWin32ContextInIDispatchAttribute System.Runtime.InteropServices.TypeLibConverter System.Runtime.Remoting.Channels.ClientChannelSinkStack System.Runtime.Remoting.Channels.ServerChannelSinkStack System.Runtime.Remoting.Channels.TransportHeaders System.Runtime.Remoting.Contexts.Context System.Runtime.Remoting.Contexts.SynchronizationAttribute System.Runtime.Remoting.InternalRemotingServices System.Runtime.Remoting.Lifetime.ClientSponsor System.Runtime.Remoting.Lifetime.LifetimeServices System.Runtime.Remoting.Messaging.OneWayAttribute System.Runtime.Remoting.Messaging.RemotingSurrogateSelector System.Runtime.Remoting.Metadata.SoapAttribute System.Runtime.Remoting.Metadata.SoapFieldAttribute System.Runtime.Remoting.Metadata.SoapMethodAttribute System.Runtime.Remoting.Metadata.SoapParameterAttribute System.Runtime.Remoting.Metadata.SoapTypeAttribute System.Runtime.Remoting.Metadata.W3cXsd2001.SoapAnyUri System.Runtime.Remoting.Metadata.W3cXsd2001.SoapBase64Binary System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDate System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDay System.Runtime.Remoting.Metadata.W3cXsd2001.SoapDuration System.Runtime.Remoting.Metadata.W3cXsd2001.SoapEntities System.Runtime.Remoting.Metadata.W3cXsd2001.SoapEntity System.Runtime.Remoting.Metadata.W3cXsd2001.SoapHexBinary System.Runtime.Remoting.Metadata.W3cXsd2001.SoapId System.Runtime.Remoting.Metadata.W3cXsd2001.SoapInteger System.Runtime.Remoting.Metadata.W3cXsd2001.SoapLanguage System.Runtime.Remoting.Metadata.W3cXsd2001.SoapMonth System.Runtime.Remoting.Metadata.W3cXsd2001.SoapName System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNcName System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNegativeInteger System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNmtoken System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNonNegativeInteger System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNonPositiveInteger System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNormalizedString System.Runtime.Remoting.Metadata.W3cXsd2001.SoapNotation System.Runtime.Remoting.Metadata.W3cXsd2001.SoapPositiveInteger System.Runtime.Remoting.Metadata.W3cXsd2001.SoapQName System.Runtime.Remoting.Metadata.W3cXsd2001.SoapTime System.Runtime.Remoting.Metadata.W3cXsd2001.SoapToken System.Runtime.Remoting.Metadata.W3cXsd2001.SoapYear System.Runtime.Remoting.ObjRef System.Runtime.Remoting.Proxies.ProxyAttribute System.Runtime.Remoting.RemotingException System.Runtime.Remoting.RemotingTimeoutException System.Runtime.Remoting.ServerException System.Runtime.Remoting.Services.EnterpriseServicesHelper System.Runtime.Remoting.Services.TrackingServices System.Runtime.Serialization.FormatterConverter System.Runtime.Serialization.Formatters.Binary.BinaryFormatter System.Runtime.Serialization.Formatters.InternalRM System.Runtime.Serialization.Formatters.SoapFault System.Runtime.Serialization.Formatters.SoapMessage System.Runtime.Serialization.ObjectIDGenerator System.Runtime.Serialization.OnDeserializedAttribute System.Runtime.Serialization.OnDeserializingAttribute System.Runtime.Serialization.OnSerializedAttribute System.Runtime.Serialization.OnSerializingAttribute System.Runtime.Serialization.OptionalFieldAttribute System.Runtime.Serialization.SerializationException System.Runtime.Serialization.SurrogateSelector System.Security.AllowPartiallyTrustedCallersAttribute System.Security.Cryptography.CryptoConfig System.Security.Cryptography.CryptographicException System.Security.Cryptography.CryptographicUnexpectedOperationException System.Security.Cryptography.CspParameters System.Security.Cryptography.DESCryptoServiceProvider System.Security.Cryptography.DSACryptoServiceProvider System.Security.Cryptography.DSASignatureDeformatter System.Security.Cryptography.DSASignatureFormatter System.Security.Cryptography.FromBase64Transform System.Security.Cryptography.HMACMD5 System.Security.Cryptography.HMACRIPEMD160 System.Security.Cryptography.HMACSHA1 System.Security.Cryptography.HMACSHA256 System.Security.Cryptography.HMACSHA384 System.Security.Cryptography.HMACSHA512 System.Security.Cryptography.MACTripleDES System.Security.Cryptography.MD5CryptoServiceProvider System.Security.Cryptography.PKCS1MaskGenerationMethod System.Security.Cryptography.RC2CryptoServiceProvider System.Security.Cryptography.RijndaelManaged System.Security.Cryptography.RIPEMD160Managed System.Security.Cryptography.RNGCryptoServiceProvider System.Security.Cryptography.RSACryptoServiceProvider System.Security.Cryptography.RSAOAEPKeyExchangeDeformatter System.Security.Cryptography.RSAOAEPKeyExchangeFormatter System.Security.Cryptography.RSAPKCS1KeyExchangeDeformatter System.Security.Cryptography.RSAPKCS1KeyExchangeFormatter System.Security.Cryptography.RSAPKCS1SignatureDeformatter System.Security.Cryptography.RSAPKCS1SignatureFormatter System.Security.Cryptography.SHA1CryptoServiceProvider System.Security.Cryptography.SHA1Managed System.Security.Cryptography.SHA256Managed System.Security.Cryptography.SHA384Managed System.Security.Cryptography.SHA512Managed System.Security.Cryptography.SignatureDescription System.Security.Cryptography.ToBase64Transform System.Security.Cryptography.TripleDESCryptoServiceProvider System.Security.Cryptography.X509Certificates.X509Certificate System.Security.HostProtectionException System.Security.HostSecurityManager
 楼主| xuanxiao 发表于 2023-3-28 22:32:18 | 显示全部楼层
System.Security.Permissions.GacIdentityPermission System.Security.Permissions.HostProtectionAttribute System.Security.Policy.AllMembershipCondition System.Security.Policy.ApplicationDirectoryMembershipCondition System.Security.Policy.ApplicationTrust System.Security.Policy.Evidence System.Security.Policy.GacInstalled System.Security.Policy.GacMembershipCondition System.Security.Policy.PolicyException System.Security.Policy.TrustManagerContext System.Security.SecurityException System.Security.SuppressUnmanagedCodeSecurityAttribute System.Security.UnverifiableCodeAttribute System.Security.VerificationException System.Security.XmlSyntaxException System.SerializableAttribute System.StackOverflowException System.STAThreadAttribute System.SystemException System.Text.ASCIIEncoding System.Text.StringBuilder System.Text.UnicodeEncoding System.Text.UTF7Encoding System.Text.UTF8Encoding System.Threading.Mutex System.Threading.Overlapped System.Threading.ReaderWriterLock System.Threading.SynchronizationLockException System.Threading.ThreadInterruptedException System.Threading.ThreadStateException System.ThreadStaticAttribute System.TimeoutException System.TypeLoadException System.TypeUnloadedException System.UnauthorizedAccessException System.Version
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表

在线客服

售前咨询
售后咨询
服务热线
023-58418553
微信公众号