From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.



Microsoft .NET で Measurement Studio の解析用 ActiveX コントロールは使用できますか。



使用ソフトウェア:
使用ソフトウェア・バージョン: N/A
使用ソフトウェア・バージョンに特化: N/A
二次のソフトウェア: Measurement Studio>>Measurement Studio for .NET Support

問題: Microsoft .NET で Measurement Studio の解析用 ActiveX コントロールは使用できますか。

解決策: .NET 上での Measurement Studio の解析用 ActiveX コントロールの使用は (CWArrray, CWComplex, CWMatrix, CWStat, CWDSP) サポートされていません。
これらのコントロールは、Visual Basic 6.0 での使用を前提に設計・実装されており、.NET 環境は使用対象外のためテストしていません。.NET 環境(Visual C# および Visual Basic .NET)では Measurement Studio .NET の解析用ライブラリの使用を強くお勧めいたします。Measurment Studio 7.0 以降に同梱されています。

しかしながら、.NET 環境でも解析用 ActiveX コントロールが実行できる場合が多々あります。

解析用 ActiveX コントロールは Visual Basic 6.0 用に設計されているので、メソッドに渡す引数は一般にバリアント型です。Visual C# や Visual Basics .NET を使用して、 .NET フォーム上に ActiveX コントロールを配置すると、Visual Studio 環境はランタイム呼び出し可能ラッパー (Runtime Callable Warpper, RCW) を生成します。RCW はデータの受け渡しに必要なマーシャリングを行います。

ほとんどの場合、 byVal/Input パラメータとしてネイティブの ADE データ型 (double、integer など) が使用できます。また、byRef/ref/output/return パラメータには object が使用できます。

以下に例を示します。

[Visual Basic]
Dim inputData(100) As Double
Dim rnd As New Random(100)
Dim i As Integer
For i = 0 To 100
inputData(i) = rnd.NextDouble() * 100
Next i

' meanValue(return value) はオブジェクトとして、inputData は double の配列として宣言
Dim meanValue = AxCWStat1.Mean(inputData)

' acEstimate, dcEstimate (いずれの出力変数) は object として宣言
Dim acEstimate, dcEstimate
AxCWDSP1.ACDCEstimator(inputData, acEstimate, dcEstimate)



[CSharp]
double[]inputData = new double[100];
Random rnd = new Random(100);
for (int i=0;i<100;++i)
inputData[i] = rnd.NextDouble()*100;
// double 型にキャスト
double mean= (double)axCWStat1.Mean(inputData);

// ref 引数は object として宣言する。
// ref なので null に初期化する。
// object を 0 に初期化できない、つまり
// object acEstimate=0, dcEstimate=0
// は不正。この場合、引数を object ではなく整数型にマーシャリングしてしまうので、
//type mismatch 例外が投げられる。
object acEstimate=null, dcEstimate=null;
axCWDSP1.ACDCEstimator(inputData,ref acEstimate, ref dcEstimate);
return;


注意 メソッド実行時に引数のデータ型が間違っていると、次のような type mismatch 例外が投げられます。

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll.
Additional information: Type mismatch.



関連リンク: ランタイム呼び出し可能ラッパー

添付:





報告日時: 12/01/2004
最終更新日: 03/30/2005
ドキュメントID: 3G0DPLPR