奇怪的System.Runtime.InteropServices.COMException错误

时间:2012-07-05 08:11:39

标签: c# winforms dll error-handling publish

我有一个Windows Forms应用程序,我在我的服务器上发布并安装,但是当我试图使用它时,遗憾地给了我这个错误:

************** Exception Text **************
System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {40942A6C-1520-4132-BDF8-BDC1F71F547B} failed due to the following error:
80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
    at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
    at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
    at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
    at System.Activator.CreateInstance(Type type, Boolean nonPublic)
    at System.Activator.CreateInstance(Type type)
    at PDFtoDoc.Form1.DoOCR(String FullPath)
    at PDFtoDoc.Form1.CheckFileAndDoOCR(String directoryPath)
    at PDFtoDoc.Form1.timer1_Tick(Object sender, EventArgs e)
    at System.Windows.Forms.Timer.OnTick(EventArgs e)
    at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

这对我来说似乎是一个“.dll”文件,但我无法弄清楚哪一个或者这是不是真正的问题。什么可能导致这个?我该如何解决呢?

1 个答案:

答案 0 :(得分:1)

这是COM Interop的问题。您需要手动将dll文件复制到应用程序或将dll文件打包到安装程序中。