Vncsharp 窗口表面项目上的错误

本文关键字:错误 项目 窗口 表面 Vncsharp | 更新日期: 2023-09-27 18:32:46

我是使用 Visual C# 2010 进行 C# 编程Microsoft新手,当我尝试使用该VncSharpWpf.dll作为参考时,我需要有关XamlParseExcepion的帮助。出现以下错误。

库和示例代码的链接来自: http://d.hatena.ne.jp/horus531/20110515/1305443108

当我尝试将相同的代码添加到作者提供的示例代码中时(即将表面库导入项目,相同的代码有效)。

我不知道是什么原因导致库每次尝试加载时在新制作的 surface 项目上崩溃。

有人可以指导我使用什么软件/方法来识别和解决此类问题吗?

错误是:

System.Windows.Markup.XamlParseException was unhandled
  Message='The invocation of the constructor on type 'TestVncSharpWpf.SurfaceWindow1' that matches the specified binding constraints threw an exception.' Line number '5' and line position '5'.
  Source=PresentationFramework
  LineNumber=5
  LinePosition=5
  StackTrace:
       at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
       at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
       at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
       at System.Windows.Application.LoadBamlStreamWithSyncInfo(Stream stream, ParserContext pc)
       at System.Windows.Application.LoadComponent(Uri resourceLocator, Boolean bSkipJournaledProperties)
       at System.Windows.Application.DoStartup()
       at System.Windows.Application.<.ctor>b__1(Object unused)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.DispatcherOperation.InvokeImpl()
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       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.Windows.Threading.DispatcherOperation.Invoke()
       at System.Windows.Threading.Dispatcher.ProcessQueue()
       at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       at System.Windows.Application.RunInternal(Window window)
       at System.Windows.Application.Run()
       at TestVncSharpWpf.App.Main() in C:'surface'TestVncSharpWpf'obj'Debug'App.g.cs:line 0
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       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: System.BadImageFormatException
       Message=Could not load file or assembly 'VncSharpWpf, Version=0.0.0.1, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
       Source=TestVncSharpWpf
       FileName=VncSharpWpf, Version=0.0.0.1, Culture=neutral, PublicKeyToken=null
       FusionLog==== Pre-bind state information ===
LOG: User = test-PC'test
LOG: DisplayName = VncSharpWpf, Version=0.0.0.1, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/surface/TestVNCSharpWPF/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : TestVncSharpWpf, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:'Windows'Microsoft.NET'Framework64'v4.0.30319'config'machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/surface/TestVNCSharpWPF/bin/Debug/VncSharpWpf.DLL.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.
       StackTrace:
            at TestVncSharpWpf.SurfaceWindow1..ctor()
       InnerException: 

Vncsharp 窗口表面项目上的错误

在错误消息的中间,它说System.BadImageFormatException 这篇文章表明问题可能是由于 32 位/64 位问题造成的。
此外,有关对此进行故障排除的文档说

  • 如果应用程序使用 32 位组件,请确保它始终作为 32 位应用程序运行
  • 确保您使用的组件不是使用不同版本的 .NET Framework 创建的。
  • 确保文件映像是有效的托管程序集或模块。