0

I've tried following several tutorials an have seem to be having trouble.

I've got an existing program that i'm trying to add a directx window to as an additional popup forum that will run as a child to the main application form.

Here is the windows form class:

public partial class DxWindow : Form
{

    Device device;

    public DxWindow()
    {

        InitializeComponent();
        initDevice();
    }

    private void initDevice()
    {
        MessageBox.Show("hello");

        PresentParameters pp = new PresentParameters();
        pp.Windowed = true;
        pp.SwapEffect = SwapEffect.Discard;

        device = new Device(0, DeviceType.Hardware, this, CreateFlags.HardwareVertexProcessing, pp);
    }

    private void Render()
    {
        //render stuff
    }

    private void DxWindow_Paint(object sender, PaintEventArgs e)
    {
        Render();
    }
}

and here is where i initialize the form (from a UI button in main window)

private void toolStripButton3_Click_1(object sender, EventArgs e)
{
    if (DirectxWindow == null)
    {
        DirectxWindow = new DxWindow();
        DirectxWindow.Show();
    }
}

When i run the program and click the button. it seems create the form in memory but never shows up. when i step through it in the debugger, it gets to "DirectxWindow = new DxWindow();" and then automatically jumps out of break mode and continues running with the main window frozen and no new Dxwindow().

when i break execution is seems to still be on "DirectxWindow = new DxWindow();"

Also, "MessageBox.Show("hello");" in the DxWindow constructor is never called"

Edit: I've deduced that as soon as it hits "PresentParameters pp = new Microsoft.DirectX.Direct3D.PresentParameters();" the application becomes unresponsive without throwing any errors.

cookie42
  • 21
  • 3

1 Answers1

1

Turns out my problem was needing to use

<startup useLegacyV2RuntimeActivationPolicy="true">

in the "App.config" File

Solution was found here: Mixed mode assembly is built against version 'v1.1.4322'

Although i never got the error as described by the OP. i simply had this problem as described in the comments: "Thank you!!!! This is the weirdest problem I'd ever encountered. In VS 2012 .Net 4.0 my application would just hang the moment I initialized any variable of a type related to this DLL. I'd never seen anything like it. Couldn't find anything about the problem until I found this!" – Quinxy von Besiex

Community
  • 1
  • 1
cookie42
  • 21
  • 3