C# 我正试图从我的硬盘播放视频avi文件,但收到FileLoadException错误为什么?
这是我在表格1中的代码:C# 我正试图从我的硬盘播放视频avi文件,但收到FileLoadException错误为什么?,c#,C#,这是我在表格1中的代码: private void play() { pictureBox1.Load(vp.PlayVideoFile(@"D:\testdata\new.avi")); } vp是我的VideoPlayer类的一个变量: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T
private void play()
{
pictureBox1.Load(vp.PlayVideoFile(@"D:\testdata\new.avi"));
}
vp是我的VideoPlayer类的一个变量:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ScreenVideoRecorder
{
class VideoPlayer
{
public VideoPlayer()
{
}
public string PlayVideoFile(string fileName)
{
//create the video
Microsoft.DirectX.AudioVideoPlayback.Video video = new Microsoft.DirectX.AudioVideoPlayback.Video(fileName);
//Play the video (put this in a buttons click event)
video.Play();
//Pause the video (put this in a buttons click event)
video.Pause();
//Stop the video (put this in a buttons click event)
video.Stop();
return fileName;
}
}
}
为什么我会得到这个例外
混合模式程序集是根据运行时版本“v1.1.4322”生成的,如果没有其他配置信息,则无法在4.0运行时中加载
它需要什么额外的配置信息?怎么做呢
System.IO.FileLoadException was unhandled
HResult=-2146232799
Message=Mixed mode assembly is built against version 'v1.1.4322' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.
Source=ScreenVideoRecorder
StackTrace:
at ScreenVideoRecorder.VideoPlayer.PlayVideoFile(String fileName)
at ScreenVideoRecorder.Form1.play() in d:\C-Sharp\ScreenVideoRecorder\ScreenVideoRecorder\ScreenVideoRecorder\Form1.cs:line 107
at ScreenVideoRecorder.Form1.timer1_Tick(Object sender, EventArgs e) in d:\C-Sharp\ScreenVideoRecorder\ScreenVideoRecorder\ScreenVideoRecorder\Form1.cs:line 58
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at ScreenVideoRecorder.Program.Main() in d:\C-Sharp\ScreenVideoRecorder\ScreenVideoRecorder\ScreenVideoRecorder\Program.cs:line 19
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.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
编辑:
现在我在视频播放器课上遇到了一个例外:
Microsoft.DirectX.AudioVideoPlayback.Video video = new Microsoft.DirectX.AudioVideoPlayback.Video(fileName);
异常情况是:检测到加载程序锁定:
DLL 'C:\WINDOWS\assembly\GAC\Microsoft.DirectX\1.0.2902.0__31bf3856ad364e35\Microsoft.DirectX.dll' is attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.
检测到LoaderLock
消息:DLL“C:\WINDOWS\assembly\GAC\Microsoft.DirectX\1.0.2902.0\uu 31bf3856ad364e35\Microsoft.DirectX.DLL”正在尝试在OS加载程序锁内执行托管。请勿尝试在DllMain或image initialization函数中运行托管代码,因为这样做可能会导致应用程序挂起。使用以下内容将app.config文件添加到项目中:
<?xml version="1.0"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v1.0"/>
<supportedRuntime version="v4.0"/>
</startup>
</configuration>
您是否尝试添加VC++运行时DLL,并且.Net不向后兼容您需要安装正确的.Net版本:(尝试Laszlokiss88我现在试过当我运行程序时我看到弹出窗口说我需要安装.NET 1.0当我单击“确定”时它将我的浏览器带到搜索引擎网页:我将此添加到app.config:但现在我在另一个地方遇到异常我用新的异常编辑我的问题。我已经下载了d it。我试图在2010年6月安装directx,但在安装结束时,它说安装失败。dll不在那里,所以我下载了它。我使用windows 8 64位和vidusal studio 2012 pro,我的项目在.net 4.0上。你能复制url吗?可能有一个4.0版本。你安装了directx软件DevKit吗?(也许您应该从此引用dll。)