Home > Software > Programming and SDK > Forum > How can I implement a C# application using a DLL without using the visual control from the toolbox?

How can I implement a C# application using a DLL without using the visual control from the toolbox?

Sep 10, 2015
Benjamin Kress wrote
I have no problem dragging the control onto the form and using it as described. However, I would like to create a library that I can use in multiple projects. I am using the MVC pattern and would like to decouple my model from my view.

If I try to create an AxDataSdk() in code I get a System.Windows.Forms.AxHost.InvalidActiveXStateException. This is because I didn't add it to the form. Is there a way to fake this?

If I try to create something from Interop.DATAQSDKLib I get all kinds of System.Runtime.InteropServices.COMException (0x8000FFFF); Catastrophic failure. This happens when I try to create a new interface DataqSDK.

Any help is appreciated.

Thanks.
Reply
4 Answers
Sep 10, 2015
Ken agent wrote
I am not aware of anyone who successfully used DataqSdk.ocx without a form. If you only need to support DI-145/149/155/245 and future Dataq products, see http://www.dataq.com/products/sdk-dot-net/dotnet-class.html.

If you need to support older Dataq devices, see http://support.dataq.com/viewtopic.php?f=5&t=4833 for someone who instead used the Win32 Dataq SDK documented at www.dataq.com/sdk, which DataqSdk.ocx uses to access the device. To fix the problems that he encountered, install the latest WinDaq software for your device. However, supporting different devices requires dynamically linking to DIxxxNT.DLL for the device and calling di_open with an argument specifying the COM port and device model number.
Sep 11, 2015
Benjamin Kress wrote
OK. I figured it out.
------------------------------------------------
using AxDATAQSDKLib;

public class DataqModel
{
private AxDataqSdk dataqUnit;

public DataqModel()
{

Sep 11, 2015
Benjamin Kress wrote
Sorry. Must have accidentally posted. Anyway...
------------------------------------------------
using AxDATAQSDKLib;

public class DataqModel
{
private AxDataqSdk dataqUnit;

public DataqModel()
{
this.dataqunit = new new AxDataqSdk();
this.dataqUnit.CreateControl(); // This line satisfies InvalidActiveXStateException problem
.....
Do things that set up and use the axtiveX control
......
}
Sep 11, 2015
Ken agent wrote
Thank you for posting your solution.