C# 如何解决缺少dll的异常?dll文件位于目录中

C# 如何解决缺少dll的异常?dll文件位于目录中,c#,.net,winforms,dll,C#,.net,Winforms,Dll,这一行: Boolean bl = InitializeDirectX(mypb); 以及使用DirectX的InitializeDirectX方法: public Boolean InitializeDirectX(PictureBox pb) { DispMode = Manager.Adapters[Manager.Adapters.Default.Adapter].CurrentDisplayMode; D3Dpp = n

这一行:

Boolean bl = InitializeDirectX(mypb);
以及使用DirectX的InitializeDirectX方法:

public Boolean InitializeDirectX(PictureBox pb)
        {
            DispMode = Manager.Adapters[Manager.Adapters.Default.Adapter].CurrentDisplayMode;
            D3Dpp = new PresentParameters();
            D3Dpp.BackBufferFormat = DispMode.Format;
            D3Dpp.PresentFlag = PresentFlag.LockableBackBuffer;

            D3Dpp.SwapEffect = SwapEffect.Discard;
            D3Dpp.PresentationInterval = PresentInterval.One; //wait for vertical sync. Synchronizes the painting with
            //monitor refresh rate for smoooth animation
            D3Dpp.Windowed = true; //the application has borders

            try
            {
                D3Ddev = new Device(Manager.Adapters.Default.Adapter, DeviceType.Hardware, pb.Handle,
                                                                           CreateFlags.SoftwareVertexProcessing, D3Dpp);
                D3Ddev.VertexFormat = CustomVertex.PositionColored.Format;
                D3Ddev.RenderState.Lighting = false;
                D3Ddev.RenderState.CullMode = Cull.CounterClockwise;

                backTexture = TextureLoader.FromStream(D3Ddev, mymem);
                scannedCloudsTexture = new Texture(D3Ddev, 512, 512, 1, Usage.Dynamic, Format.A8R8G8B8, Pool.Default);

                //sprite is used to draw the texture
                D3Dsprite = new Sprite(D3Ddev);

                return true;
            }
            catch
            {
                return false;
            }
        }
在以下行中引发异常:

Boolean bl = InitializeDirectX(mypb);
异常为FileNotFoundException:

A first chance exception of type 'System.IO.FileNotFoundException' occurred in My Weather Station.exe

Additional information: Could not load file or assembly 'Microsoft.DirectX.Direct3DX.dll' or one of its dependencies. The specified module could not be found.
文件Microsoft.DirectX.Direct3DX.dll确实存在于我在参考资料中看到的文件目录中。我也没有在这个dll的引用中看到任何黄色或其他文件丢失的状态

我以前没有异常,所以就像dll文件中发生了变化一样

System.IO.FileNotFoundException occurred
  _HResult=-2147024770
  _message=Could not load file or assembly 'Microsoft.DirectX.Direct3DX.dll' or one of its dependencies. The specified module could not be found.
  HResult=-2147024770
  IsTransient=false
  Message=Could not load file or assembly 'Microsoft.DirectX.Direct3DX.dll' or one of its dependencies. The specified module could not be found.
  Source=My Weather Station
  FileName=Microsoft.DirectX.Direct3DX.dll
  FusionLog=""
  StackTrace:
       at mws.ScanningClouds.InitializeDirectX(PictureBox pb)
       at mws.ScanningClouds.ScanClouds_Load(Object sender, EventArgs e) in d:\C-Sharp\myprog.cs:line 179
  InnerException:
第179行是:

Boolean bl = InitializeDirectX(mypb);
如果dll中缺少某些依赖项,我不知道为什么,我如何才能找到它们,如果有的话

Udate:

这是文件DirectXDirect3DX.dll的dotPeek中的引用

在我的项目中:


我不理解t.S解决方案中的记事本部分

更新

这是我的项目文件中的引用:

<Reference Include="AviFile">
      <HintPath>C:\Temp\avifilewrapper\aviFileWrapperDemo_src\AviDemo\bin\Debug\AviFile.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.DirectX, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>C:\Temp\radarscan\dlls\DLL'S\Microsoft.DirectX.DLL</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="Microsoft.DirectX.Direct3D, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>C:\Temp\radarscan\dlls\DLL'S\Microsoft.DirectX.Direct3D.DLL</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="Microsoft.DirectX.Direct3DX, Version=1.0.2909.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>C:\Temp\radarscan\dlls\DLL'S\Microsoft.DirectX.Direct3DX.DLL</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="NumericComparer">
      <HintPath>C:\Temp\csnsort\csnsort_src\NumericComparer.dll</HintPath>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.Core">
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    </Reference>
    <Reference Include="System.Speech" />
    <Reference Include="System.Web" />
    <Reference Include="System.Xml.Linq">
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    </Reference>
    <Reference Include="System.Data.DataSetExtensions">
      <RequiredTargetFramework>3.5</RequiredTargetFramework>
    </Reference>
    <Reference Include="System.Data" />
    <Reference Include="System.Deployment" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Xml" />
    <Reference Include="unfreez_wrapper, Version=1.0.4362.38939, Culture=neutral, processorArchitecture=x86">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\..\..\..\New folder\Unfreez\unfreez_wrapper\Release\unfreez_wrapper.dll</HintPath>
    </Reference>
    <Reference Include="ZedGraph">
      <HintPath>..\..\..\..\Appz\zedgraph_dll_v515_1\zedgraph_dll_v515\zedgraph_dll_v5.1.5\ZedGraph.dll</HintPath>
    </Reference>
    <Reference Include="ZedGraph.Web">

C:\Temp\avifilewrapper\aviFileWrapperDemo\u src\AviDemo\bin\Debug\AviFile.dll
假的
C:\Temp\radarscan\dlls\DLL的\Microsoft.DirectX.DLL
真的
假的
C:\Temp\radarscan\dlls\DLL的\Microsoft.DirectX.Direct3D.DLL
真的
假的
C:\Temp\radarscan\dlls\DLL的\Microsoft.DirectX.Direct3DX.DLL
真的
C:\Temp\csnsort\csnsort\U src\NumericComparer.dll
3.5
3.5
3.5
假的
..\..\..\..\New folder\Unfreez\Unfreez\u wrapper\Release\Unfreez\u wrapper.dll
..\..\..\..\Appz\zedgraph_dll_v515_1\zedgraph_dll_v515\zedgraph_dll_v5.1.5\zedgraph.dll

您的计算机上可能没有安装Directx的组件或部分。在您的计算机上安装
DirectX
可以解决此问题。

检查依赖项-下载名为
dotPeek
的应用程序。安装并运行它。加载dll并查看引用。现在,在记事本中打开您的项目文件,找到有关dll引用的所有信息,并将其粘贴到您的问题中。谢谢,我不明白记事本的部分。我在问题中添加了两个截图。你说的项目文件是什么意思?我的项目名称cs文件?或visual studio解决方案文件?@Daniel:T.S.意味着您应该在文本编辑器中打开项目文件(
.csproj
),并查找提及部件名称/引用的零件。然后将项目文件的整个部分复制并粘贴到您的问题中。这背后的原因是,查看项目文件有时比查看中的引用更有说服力,而检查的内容更多:1。您是否缺少(正确版本的)
Microsoft.VisualC
?看来,您需要安装正确的VisualC++运行时/可重新分配。2.您是否已安装(最新版本的)DirectX,以及正在使用的这些SDK DLL的最新/匹配版本?3.你试过编译32位和64位吗?问题是我的directx dll文件很旧,它们的版本是:1.1.4322,我找不到在windows 8.1 pro上安装directx 9或其他东西的方法。我的项目需要此dll版本。我可以将我的项目或此表单/类上载到某个网站,以便您可以查看。如何在windows 8.1 pro上安装directx?我看到它应该通过windows update,但我没有任何更新。