【发布时间】:2014-01-03 18:21:04
【问题描述】:
问题:在运行 WPF 应用程序时,我得到:
例外
类型的第一次机会异常 'System.Windows.Markup.XamlParseException' 发生在 PresentationFramework.dll
内部异常:类未注册
控制台打印异常:
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in System.Windows.Forms.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in System.Windows.Forms.dll
System.Runtime.InteropServices.COMException (0x80040154): Klasa niezarejestrowana. (Wyjatek od HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
w System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance(Guid& clsid, Object punkOuter, Int32 context, Guid& iid)
w System.Windows.Forms.AxHost.CreateWithoutLicense(Guid clsid)
w System.Windows.Forms.AxHost.CreateWithLicense(String license, Guid clsid)
w System.Windows.Forms.AxHost.CreateInstanceCore(Guid clsid)
w System.Windows.Forms.AxHost.CreateInstance()
w System.Windows.Forms.AxHost.GetOcxCreate()
w System.Windows.Forms.AxHost.TransitionUpTo(Int32 state)
w System.Windows.Forms.AxHost.CreateHandle()
w System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
w System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
w System.Windows.Forms.AxHost.EndInit()
w HomeSecurity.VideoStream.InitializeComponent() w c:\Users\R\Documents\Visual Studio 2013\Projects\HomeSecurity\HomeSecurity\VideoStream.Designer'HomeSecurity.vshost.exe' (CLR v4.0.30319: HomeSecurity.vshost.exe): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\UIAutomationTypes\v4.0_4.0.0.0__31bf3856ad364e35\UIAutomationTypes.dll'. Symbols loaded.
.cs:wiersz 48
w HomeSecurity.VideoStream..ctor() w c:\Users\R\Documents\Visual Studio 2013\Projects\HomeSecurity\HomeSecurity\VideoStream.cs:wiersz 13
w HomeSecurity.MainWindow..ctor() w c:\Users\R\Documents\Visual Studio 2013\Projects\HomeSecurity\HomeSecurity\MainWindow.xaml.cs:wiersz 23
The thread 0x1198 has exited with code 0 (0x0).
在 WPF 项目中,我有 MainWindow,默认自动生成 XAML:
<Window x:Class="HomeSecurity.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid x:Name="Grid">
</Grid>
</Window>
在 .cs 文件中我只实例化了VideoStream
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
VideoStream VideoStream = new VideoStream();//THAT LINE PRODUCES THE EXCEPTION
}
}
VideoStream 是 Form。这个表单包含一个名为AxisMediaControl Class 的ActiveX 控件,它看起来像这样。 .cs 文件中没有额外的代码。
注意:WinForms 应用程序中的相同表单不会导致任何问题。从此表单中删除 ActiveX 控件会删除异常(在 WPF 中)。
已添加以下引用:
内部异常:
【问题讨论】:
-
检查内部异常。
-
@RohitVats 感谢您抽出宝贵时间。我在底部添加了内部异常。请刷新
-
似乎是一些 COM 异常,与 WPF 无关。对不起,但我不知道。 :(
-
COMException 的 ErrorCode 值是多少?
-
您的 winforms 应用程序是否在 WPF 应用程序失败的同一台机器上成功运行?如果是,则可能是 64/32 位兼容性问题。您的 WPF 应用程序是 64 位的吗? winforms 应用呢?
标签: c# wpf winforms xaml activex