static internal bool VerifyInterface(ComAdminInterfaceInfo interfaceInfo, bool allowReferences, Guid clsid, bool produceError) { if (IsInternalInterface(interfaceInfo.Iid)) { if (produceError) { ToolConsole.WriteError(SR.GetString(SR.IsInternalInterfaceAndCannotBeExposedOverWebService, Tool.Options.ShowGuids ? interfaceInfo.Iid.ToString("B") : interfaceInfo.Name), ""); } else { ToolConsole.WriteWarning(SR.GetString(SR.IsInternalInterfaceAndCannotBeExposedOverWebService, Tool.Options.ShowGuids ? interfaceInfo.Iid.ToString("B") : interfaceInfo.Name)); } return(false); } Type typeOfInterfaceResolver = typeof(Message).Assembly.GetType("System.ServiceModel.ComIntegration.TypeCacheManager"); object resolver = typeOfInterfaceResolver.InvokeMember("Provider", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.GetProperty, null, null, null, CultureInfo.InvariantCulture); object[] args = new object[1] { interfaceInfo.Iid }; Type typeOfInterface = null; try { typeOfInterface = typeOfInterfaceResolver.InvokeMember("VerifyType", BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance, null, resolver, args, CultureInfo.InvariantCulture) as Type; } catch (TargetInvocationException e) { if (e.GetBaseException() is System.IO.FileNotFoundException) { throw CreateDescriptiveException((System.IO.FileNotFoundException)e.GetBaseException()); } string exceptionMessage = SR.GetString(SR.TypeResolutionForInterfaceFailed, Tool.Options.ShowGuids ? interfaceInfo.Iid.ToString("B") : interfaceInfo.Name, e.InnerException.Message); if (DerivesFromServicedComponent(interfaceInfo.Iid, clsid)) { exceptionMessage += " " + SR.GetString(SR.ClassInterfacesNotSupported); } if (produceError) { ToolConsole.WriteError(exceptionMessage, ""); } else { ToolConsole.WriteNonVerboseWarning(exceptionMessage); } return(false); } MethodInfo[] methods = typeOfInterface.GetMethods(); if (methods.Length == 0) { if (produceError) { ToolConsole.WriteError(SR.GetString(SR.InterfaceHasNoMethods, Tool.Options.ShowGuids ? interfaceInfo.Iid.ToString("B") : interfaceInfo.Name), ""); } else { ToolConsole.WriteNonVerboseWarning(SR.GetString(SR.InterfaceHasNoMethods, Tool.Options.ShowGuids ? interfaceInfo.Iid.ToString("B") : interfaceInfo.Name)); } return(false); } string typeMismatchDetails; foreach (MethodInfo method in methods) { foreach (ParameterInfo parameter in method.GetParameters()) { Type typeOfParam = parameter.ParameterType; if (typeOfParam.IsByRef) { typeOfParam = typeOfParam.GetElementType(); } if (!IsValidParameter(typeOfParam, parameter, allowReferences, out typeMismatchDetails)) { if (produceError) { ToolConsole.WriteError(SR.GetString(SR.ParameterOfMethodInInterfaceHasANonCompliantType, Tool.Options.ShowGuids ? interfaceInfo.Iid.ToString("B") : interfaceInfo.Name, method.Name, parameter.Name, typeMismatchDetails), ""); } else { ToolConsole.WriteNonVerboseWarning(SR.GetString(SR.ParameterOfMethodInInterfaceHasANonCompliantType, Tool.Options.ShowGuids ? interfaceInfo.Iid.ToString("B") : interfaceInfo.Name, method.Name, parameter.Name, typeMismatchDetails)); } return(false); } } if (!IsValidParameter(method.ReturnType, method.ReturnTypeCustomAttributes, allowReferences, out typeMismatchDetails)) { if (produceError) { ToolConsole.WriteError(SR.GetString(SR.InvalidWebServiceReturnValue, method.ReturnType.Name, method.Name, Tool.Options.ShowGuids ? interfaceInfo.Iid.ToString("B") : interfaceInfo.Name, typeMismatchDetails), ""); } else { ToolConsole.WriteNonVerboseWarning(SR.GetString(SR.InvalidWebServiceReturnValue, method.ReturnType.Name, method.Name, Tool.Options.ShowGuids ? interfaceInfo.Iid.ToString("B") : interfaceInfo.Name, typeMismatchDetails)); } return(false); } } return(true); }