08-13-2010 10:35 AM
Hello,
I made a C# application including measurement studio forms.
One feature of the application is that I can start DIAdem and open then a tdms file - that is working.
But if I install the application on a computer without a DIAdem installation the C# application doesn't start anymore.
Is there are opportunity to tell C# not to load the diadem.dll or is there a pseudo DIADEM what tells the DLL DIAdem is not accessible?
Best Regards Joerg Koch
Solved! Go to Solution.
08-15-2010 05:11 PM
Hi Joerg,
What is this "diadem.dll" that you refer to? the normal mechanism to communicate with DIAdem from an outside compiler is to use the DIAdem ActiveX servers (DIAdem.ToCommand and DIAdem.ToDataSheet). If you use this method, then you can attempt to connect to either of these ActiveX servers with error suppression engaged-- you either get back an object variable or you don't.
The other point is that you don't really need DIAdem to open a TDMS file. You mention that you have MeasurementStudio forms, but MeasurementStudio has a built-in API to read and write TDMS files.
How is your C# application really communicating with DIAdem?
Brad Turpin
DIAdem Product Support Engineer
National Instruments
08-16-2010 02:27 AM
Hey Brad,
if you add the Reference DIAdem in your visual studio project, the file Interop.DIAdem.dll is added to your executable later.
See the the attached picture.
I like to open the selected TDMS file in DIAdem for more analysis with the following code
private
{
// Bring DIAdem to front when we open it and display the View window
void ButtonOpenTdmsInDiadem_Click(object sender, EventArgs e)oDIAdem.CmdExecuteSync("WndShow('SHELL','MINIMIZE')");
oDIAdem.CmdExecuteSync("WndShow('VIEW','Show')");
// delete all entries
oDIAdem.CmdExecuteSync(
// open the selected Diadem file
oDIAdem.CmdExecuteAsync("DataFileImport('" + tdmsFileName + "')");
"DATADELALL(True)");
The problem isn't to find out if DIAdem is installed, the problem is the application is starting the DIAdem interface when it is lunched.
Best regards
Joerg
08-16-2010 10:19 AM
Hi Joerg,
Unfortunately I'm advising you with one hand tied behind my back, because I've only dabbled in C and never to the extent of calling out to any other program's ActiveX interface. I have controlled DIAdem many times from LabVIEW and VBScript using DIAdem's ActiveX servers, and the commands sent are identical to what would be sent from C. What's not identical is the linking and compiling details, which are completely hidden or absent in LabVIEW and VBScript.
Still, I really don't understand why DIAdem would launch when you start your C# program, unless your C# program is invoking an ActiveX object immediately when it launches. If you are intentionally doing this, then I'd like to recommend that you restructure that command so that your program has a chance to launch without DIAdem. When you run a LabVIEW or VBScript program that controlls DIAdem, the DIAdem icon never appears in the system tray UNTIL the first ActiveX call is made to DIAdem, so I have to believe there is a way to organize your C# code to achieve the same result. I suppose it's possible C# may automatically launch all servers declared in the compiled code, but I would consider that a language architecture flaw for this particular application.
Can you comment on when your first DIAdem.ToCommand or DIAdem.ToDatSheet call occurs in your C# code?
Brad Turpin
DIAdem Product Support Engineer
National Instruments
08-16-2010 11:04 AM
Hi Brad,
thanks for your comments.
You are right, the problem was the location of the intialization of the DIAdem class.
Also I haven't had an exception handler.
The following code is now working.
It has only one little issue now, that to keep DIAdem open you have to start it first before you push the butten.
If not DIAdem will close as soon as you click on the C# application again, because the DIAdem instance is destroyed after the sub programm is finished.
using DIAdem;
private void ButOpenTdmsInDiadem_Click(object sender, EventArgs e)
{
try
{
this.Cursor = Cursors.WaitCursor;
// the new command will cause an exception if there is no DIAdem installed on the computer
DIAdem.TOCommand oDIAdem = new DIAdem.TOCommand();
// Bring DIAdem to front when we open it and display the View window
oDIAdem.CmdExecuteSync("WndShow('SHELL','MINIMIZE')");
oDIAdem.CmdExecuteSync("WndShow('VIEW','Show')");
// delete all entries
oDIAdem.CmdExecuteSync("DATADELALL(True)");
// open the selected Diadem file
oDIAdem.CmdExecuteAsync("DataFileImport('" + tdmsFileName + "')");
this
}
catch
{
.Cursor = Cursors.Default;
// if there is no DIAdem installed we hide the control to move open the tdms file in DIAdem
ButOpenTdmsInDiadem.Visible = false;
}
}
08-17-2010 09:56 AM
Hi Joerg,
I'm glad you hear you're making progress. The DIAdem ActiveX servers will by default connect to any already existing DIAdem instance and leave it unmolested when they end. If instead no DIAdem instance exists when the ActiveX server is invoked, then the ActiveX request will start a dependent child DIAdem instance that shuts down automatically when the calling program ends. What most people do is create the ActiveX connection variable at the beginning of the application and hang onto it until the very end of the application, even if no DIAdem activity is happening for long stretches of time. If the connection object variable persists, so will the DIAdem instance, even a dependent child DIAdem instance. Do you think that would be an option for you?
Brad Turpin
DIAdem Product Support Engineer
National Instruments
11-15-2013 03:22 PM
Hi Joerg,
Can you please tell me where did you the diadem.dll or interop.DIAdem.dll??
Thanks in advance.
EagleEye.
11-18-2013 05:21 AM
Hello EagleEye,
I can find the Interop.DIAdem.dll in the ../obj Folder of my C# project. Later the compiler transfers it to the .../bin folder.
Cioa Joerg