2014-03-24 67 views
0

最初,QuickTime OCX似乎暫時工作。在Visual Studio中我做了以下內容:如何讓QuickTime OCX控件正確註冊並在.Net中工作

  • 添加了QuickTime Plugin Control在工具窗格中的工具箱通過右鍵點擊 - >選擇工具箱項 - > COM組件 - >檢查的QuickTime插件控制,OK。
  • 將控件從工具箱拖到我的空表單上。

它顯示了一個帶有QuickTime Logo的面板。然後我去了代碼視圖,並通過intellisense探索了一些屬性和方法(我想用它自動化一些AAC編碼)。

切換回設計器視圖後,Visual Studio崩潰了,從此我再也無法獲得任何東西了。我已經從解決方案中刪除了所有引用並重新啓動了Visual Studio。試圖刪除並重新添加控件工具箱(這部分作品),但只要我嘗試將其拖動到我的形式,我得到以下錯誤:

Failed to create component 'AxHost'. The error message follows: 
'System.InvalidOperationException: Unable to initialize component. 
    at System.Windows.Forms.AxHost.DepersistControl() 
    at System.Windows.Forms.AxHost.ActivateAxControl() 
    at System.Windows.Forms.AxHost.TransitionUpTo(Int32 state) 
    at System.Windows.Forms.AxHost.CreateHandle() 
    at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) 
    at System.Windows.Forms.Control.CreateControl() 
    at System.Windows.Forms.Control.ControlCollection.Add(Control value) 
    at System.Windows.Forms.Form.ControlCollection.Add(Control value) 
    at System.Windows.Forms.Design.ParentControlDesigner.AddChildControl(Control newChild) 
    at System.Windows.Forms.Design.ParentControlDesigner.AddControl(Control newChild, IDictionary defaultValues) 
    at System.Windows.Forms.Design.ControlDesigner.InitializeNewComponent(IDictionary defaultValues) 
    at System.Windows.Forms.Design.AxHostDesigner.InitializeNewComponent(IDictionary defaultValues)' 

我也試過的QuickTime修復通過Control Panel\All Control Panel Items\Programs and Features - >修理,無濟於事。

然後我試圖重新註冊DLL:

regsvr32 "C:\Program Files (x86)\QuickTime\QTPlugin.ocx" 

結果:

DllRegisterServer in C:\Program Files (x86)\QuickTime\QTPlugin.ocx succeeded. 

再審使用它,但沒有運氣,然後嘗試這樣:

regsvr32 /i "C:\Program Files (x86)\QuickTime\QTPlugin.ocx" 

結果:

The module "C:\Program Files (x86)\QuickTime\QTPlugin.ocx" was loaded but the entry-point DllInstall was not found. 
Make sure that "C:\Program Files (x86)\QuickTime\QTPlugin.ocx" is a valid DLL or OCX file and then try again. 

不知道該從哪裏出發。它工作簡單,然後打破了,如何解決?

+1

你可以在VS之外播放QT文件嗎?你最初是如何安裝QT的? – Papa

+0

@Papa,播放和編碼我的解決方案之外的所有作品,我已經安裝了幾年QT,總是更新,在開始嘗試OCX之前從未遇到任何問題。實際上,該控件在FireFox中仍然可以正常工作(剛測試過)。 –

+1

你嘗試開始一個新的VS項目?我有一些時髦的事情發生在VS,我只需從scatch重新啓動。 – Papa

回答

0

除了最初的QuickTime OCX問題,我發現InvalidOperationException從System.Windows.Forms.AxHost.DepersistControl()發生是因爲ActiveX控件缺少IPersistStreamInit,IPersistStream或IPersistStorage接口。 AxHost需要其中之一,因此請確保在創建ATL ActiveX控件時包含其中之一。

對於像我這樣的人,在將自定義ATL ActiveX控件添加到WinForms時遇到麻煩。查找MSDN以獲取有關IPersist接口的更多詳細信息。