相互運用機能を使用して C++ COM コンポーネントを呼び出していますが、マーシャリングにはパラメーターの 1 つをref Byteとして渡す必要があります。引数は実際には文字列です。文字列 (または char 配列) を Byte に変換してこのメソッドに渡すにはどうすればよいですか?
メソッド IDL
[helpstring("method Read")]
HRESULT _stdcall Read(
[in] unsigned char* path,
[in] unsigned char command,
[in] unsigned char nShortAddr,
[out] short* pnDataSize,
[out] unsigned char** ppbyData,
[out] unsigned long* pnError);
IL
.method public hidebysig newslot virtual
instance void Read([in] uint8& path,
[in] uint8 command,
[in] uint8 nShortAddr,
[out] int16& pnDataSize,
[out] native int ppbyData,
[out] uint32& pnError) runtime managed internalcall
Visual Studio に表示されるラッパーのメソッド
public virtual void Read(ref byte path, byte command, byte nShortAddr,
out short pnDataSize, System.IntPtr ppbyData, out uint pnError)