2
我想問一下如何正確地將我的C#DLL暴露給vb6。 公開dll的目的是爲VB6應用程序使用WCF服務,因爲它不能直接使用Wcf服務。將c#DLL暴露給VB6時出錯
下面是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