【发布时间】:2015-10-03 01:13:58
【问题描述】:
这一行:
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 中的某些依赖项丢失了,不知道为什么,我怎样才能找到哪些依赖项?
日期:
这是文件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">
【问题讨论】:
-
检查依赖项 - 下载名为
dotPeek的应用程序。安装并运行它。加载您的 dll 并查看参考资料。现在,在记事本中打开您的项目文件,找到有关引用您的 dll 的所有信息并将其粘贴到您的问题中。谢谢 -
记事本部分没看懂。我在我的问题中添加了两个屏幕截图。你说的项目文件是什么?我的项目名称 cs 文件?还是 Visual Studio 解决方案文件?
-
@Daniel:T.S.意味着您应该在文本编辑器中打开您的项目文件 (
.csproj) 并查找提及程序集名称/引用的部分。然后将项目文件的整个部分复制并粘贴到您的问题中。这背后的原因是,有时查看项目文件比查看 VS 中的引用更能说明问题。 -
要检查的更多内容:1. 您是否可能缺少
Microsoft.VisualC的(正确版本)?看来您需要安装正确的 Visual C++ 运行时/可再发行组件。 2. 您是否安装了 DirectX(最新版本)以及您正在使用的这些 SDK DLL 的最新/匹配版本? 3. 您是否尝试过同时编译 32 位和 64 位? -
问题是我的directx dll文件太旧了,它们是版本:1.1.4322,我找不到在windows 8.1 pro上安装directx 9或其他东西的方法,我的项目需要这个dll版本.我可以将我的项目或此表单/类上传到某个站点,以便您可以看到它。