如何将数据从C#传递到dll

时间:2017-03-02 11:17:48

标签: c# dll vb6

我在vb中有一个名为FamServer的项目。其中,有一个名为FamApp的类。在该类中,可以使用名为FamEnroll的函数。 我已将此项目转换为dll。我已将此dll添加到我的项目中。 dll中的famenroll函数定义如下:

Public Function FamEnroll(strName As String, strEnrollTemplate As String, strIP As String) As String

我已通过以下代码调用此dll:

FamServer.FamApp famApp = new FamServer.FamApp();

          famApp.FamEnroll(name, Request.Form["LearnModel"], Request.ServerVariables["REMOTE_ADDR"]);

但是当我运行此代码时,我收到以下错误:

Exception Details: System.InvalidCastException: Unable to cast COM object of type 'FamServer.FamAppClass' to interface type 'FamServer._FamApp'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{B2CC832C-CF23-4023-9C87-711F425EC323}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

堆栈跟踪如下:

[InvalidCastException: Unable to cast COM object of type 'FamServer.FamAppClass' to interface type 'FamServer._FamApp'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{B2CC832C-CF23-4023-9C87-711F425EC323}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).]
   System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, IntPtr& ppTarget, Boolean& pfNeedsRelease) +0
   FamServer.FamAppClass.FamEnroll(String& strName, String& strEnrollTemplate, String& strIP) +0
   famenroll2.Page_Load(Object sender, EventArgs e) in f:\ASP.NET Projects\ASPNET\famenroll2.aspx.cs:27
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
   System.Web.UI.Control.OnLoad(EventArgs e) +95
   System.Web.UI.Control.LoadRecursive() +59
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +678

为什么我收到此错误?我该如何解决这个错误?请帮我 。

0 个答案:

没有答案