我目前正在尝试使用我的 C# 应用程序中的第三方 DLL。我已经注册了 DLL 并将其添加为 COM 组件列表中的引用。据我了解,这应该创建必要的互操作类来从 C# 访问这个 DLL。
在尝试从 DLL 中调用任何方法时,我得到以下异常:-
System.Runtime.InteropServices.COMException was unhandled
Message=Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
Source=mscorlib
ErrorCode=-2147418113
StackTrace:
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at OCXDLL._OCXDLL.MyMethod(Int32 param0, String param1, String param2, String param3, Int32 param4)
at MyApplication.Program.Main(String[] args) in C:\MyApplication\Program.cs:line 29
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
我用来调用库的代码:-
using OCXDLL;
namespace MyApplication
{
class Program
{
static void Main(string[] args)
{
OCXDLL libObj = new OCXDLL();
libObj.MyMethod(....);
}
}
}
请注意,这不是一个 ActiveX 控件(我已经看到了许多解决此问题的解决方案)。
有人对我哪里出错有任何想法吗?
谢谢