Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7611015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:33:37+00:00 2026-05-31T01:33:37+00:00

Trying to make a screenshot with SlimDX: using System; using System.ComponentModel; using System.Data; using

  • 0

Trying to make a screenshot with SlimDX:

using System;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using SlimDX.Direct3D9;
using SlimDX;

namespace dxcapture
{

    public partial class Form1 : Form
    {
        public Device device;

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            using (SlimDX.Direct3D9.Surface surface = device.GetRenderTarget(0))
            {
                using (SlimDX.Direct3D9.Surface surface2 = SlimDX.Direct3D9.Surface.CreateOffscreenPlain(device, surface.Description.Width, surface.Description.Height, surface.Description.Format, SlimDX.Direct3D9.Pool.SystemMemory))
                {
                    device.GetRenderTargetData(surface, surface2);
                    Bitmap bitmap = new Bitmap(SlimDX.Direct3D9.Surface.ToStream(surface2, SlimDX.Direct3D9.ImageFileFormat.Bmp, new Rectangle(0, 0, 110, 110)));
                    bitmap.Save(@"c:\wqwqwqwqwqwqwqwq.bmp");
                }
            }

        }

    }
}

Getting an error:

NullReferenceException was unhandled.
Object reference not set to an instance of an object.

at the line:

using (SlimDX.Direct3D9.Surface surface = device.GetRenderTarget(0))

What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:33:38+00:00Added an answer on May 31, 2026 at 1:33 am

    You never initialize ‘device’.

    You havepublic Device device; in the class definition but its never assigned.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Heres a screenshot to make it clear. I'm trying to figure out a robust
Trying to make a generic PL/SQL procedure to export data in specific XML format,
Trying to make a custom :confirm message for a rails form that returns data
I am trying to make a WPF app (regular Windows app, not XBAP or
I'm trying to make a text field and a button appear like they are
I'm trying since a week to make screenshot from the clients pc and send
I'm trying to make a dynamically sizable title banner, using fairly simple image tricks.
I'm trying to draw in the currently selected system font using the ATSU api
Using XNA, I'm trying to make an adventure game engine that lets you make
Im trying to make a small screenshot program, im making a small WPF window

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.