我想问我如何正确地将我的 C# DLL 暴露给 vb6。公开 dll 的目的是为 VB6 应用程序使用 WCF 服务,因为它不能直接使用 Wcf 服务。
下面是c#中的代码
[Guid("116CCA1E-7E39-4515-9849-90790DA6431E")]
[ClassInterface(ClassInterfaceType.None),ComSourceInterfaces(typeof(ITestBillerV10Service))]
[ComVisible(true)]
public class TestBillerV10 : ITestBillerV10Service
{
TestBillerInquiry.TestBillerInquiryClient _TestBillerInquiry;
public TestBillerV10()
{
_TestBillerInquiry = new TestBillerInquiry.TestBillerInquiryClient();
System.Net.ServicePointManager.Expect100Continue = false;
}
/// <summary>
/// Inquire if account no is valid or not
/// </summary>
/// <param name="accountNo">Account No. to check</param>
/// <param name="userId">User Id of the terminal</param>
/// <returns>string array Index[0] = response Code(Yes/No), Index[1] = Description for Response, Index[2] = Error Code if response code is No</returns>
[ComVisible(true)]
[DispId(1)]
public string[] Inquiry(string accountNo, string userId)
{
var newInquiry = new TestBillerInquiry.TestBillerInquiryRequest {AccountNumber = accountNo, UserId= userId };
TestBillerInquiry.TestBillerInquiryResponse response = _TestBillerInquiry.Inquiry(newInquiry);
var retVal = new string[3];
retVal[0] = response.Response;
retVal[1] = response.Message;
retVal[2] = response.Error;
return retVal;
}
}
和下面的简单界面
/// <summary>
/// Inquire if account no is valid or not
/// </summary>
/// <param name="accountNo">Account No. to check</param>
/// <param name="userId">User Id of the terminal</param>
/// <returns>string array Index[0] = response Code(Yes/No), Index[1] = Description for Response, Index[2] = Error Code if response code is No</returns>
[ComVisible(true)]
public interface ITestBillerV10Service
{
[DispId(1)]
string[] Inquiry(string accountNo, string userId);
}
下面是我如何尝试在 vb6 上使用它,但它返回一个
运行时错误 429,表示 Acvtive X 组件无法创建对象。
Dim testBillerV10 As V10Bridge.testBillerV10
Set testBillerV10 = New testBillerV10