I'm currently learning SlimDX, I want to load a Shader from tutorial which is named "triangle.fx" and it is in a folder called "FX",everything is in my solution. When I'm typing this line of code:

 using (var bytecode = ShaderBytecode.CompileFromFile(@"FX/triangle.fx", "PShader", "ps_4_0", ShaderFlags.None, EffectFlags.None))

I'm getting FileNotFoundException, and I don't know why because everything exists in my solution.

  • \$\begingroup\$ I'm learning from tutorials from the homepage of Slimdx. Even when I'm downloading the sample solution from the website, I'm getting the same error :( \$\endgroup\$ – user78174 Jan 25 '16 at 17:14
  • \$\begingroup\$ Are your files being copied to the build target? \$\endgroup\$ – RobStone Jan 26 '16 at 13:40
  • \$\begingroup\$ @RobStone, well I've just added a folder called "FX", then I have created a file called triangle.txt (because VS doesnt have any function for creating them), and I have changed it's extension to *.fx \$\endgroup\$ – user78174 Jan 26 '16 at 18:43
  • \$\begingroup\$ The FX folder is in the same directory as the built .exe? \$\endgroup\$ – RobStone Jan 26 '16 at 18:44
  • \$\begingroup\$ @RobStone The .exe file is in bin/Debug/ And the FX folder is in the MySlimDXProject3 folder,same as bin folder \$\endgroup\$ – user78174 Jan 26 '16 at 18:50

Make sure the FX folder is a subdirectory of the folder containing the .exe. In this case /bin/debug/FX

| improve this answer | |
  • \$\begingroup\$ But in the sample from slimdx.org it isn't. This sounds silly. \$\endgroup\$ – user78174 Jan 26 '16 at 19:48
  • \$\begingroup\$ That project is likely set to copy the folder when it builds \$\endgroup\$ – RobStone Jan 26 '16 at 19:49
  • \$\begingroup\$ Wow,It worked, thank you kindly :). By the way, you said that the project from slimdx.org is "set to copy the folder when it builds", how can I do the same with mine ? \$\endgroup\$ – user78174 Jan 26 '16 at 19:52
  • \$\begingroup\$ You should be able to right click the folder in the solution explorer to change build actions. The option you want might be content, though I can't recall it from my mobile. \$\endgroup\$ – RobStone Jan 26 '16 at 19:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.