I am using the following code for screencapture using SlimDX.DirectX.
public static Bitmap CaptureRegionDirect3D(IntPtr handle, Rectangle region)
{
Direct3D _direct3D9 = new Direct3D();
IntPtr hWnd = IntPtr.Zero;
Bitmap bitmap = null;
try
{
Device device;
PresentParameters parameters = new PresentParameters();
parameters.Windowed = true;
parameters.Multisample = MultisampleType.None;
parameters.FullScreenRefreshRateInHertz = 0;
parameters.PresentationInterval = PresentInterval.Default;
parameters.SwapEffect = SwapEffect.Discard;
device = new Device(new Direct3D(), 0, DeviceType.Hardware, IntPtr.Zero, CreateFlags.SoftwareVertexProcessing, parameters);
Surface s = Surface.CreateOffscreenPlain(device, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, Format.A8R8G8B8, Pool.SystemMemory);
device.GetFrontBufferData(0, s);
bitmap = new Bitmap(Surface.ToStream(s, ImageFileFormat.Bmp, new Rectangle(region.Left, region.Top, region.Width, region.Height)));
}
catch (Exception exp)
{
throw;
}
return bitmap;
}
I am getting an error at runtime stating "Could not load file or assembly 'SlimDX, Version=4.0.13.43, Culture=neutral, PublicKeyToken=b1b0c32fd1ffe4f9' or one of its dependencies. An attempt was made to load a program with an incorrect format." There are post regarding this which states to install SlimDX runtime .NET 4 into the system.
I am developing a setup .exe file so if i run this code on another machine which does not have the SlimDX runtime installed it gives me an error. I dont know what the error means and how to solve it without using SlimDX runtime installation. I want the my setup to work without the SlimDX runtime installed on the user machine. Is it better to use SlimDX or SharpDX for screen capture?. Please HELP!!!