私は昨日C++で作業を始めたばかりで、些細な問題だと思うことに固執しています。メインDLLクラスがエラーC2653を生成しています:'Marshal':はクラスまたは名前空間名ではありません。
このクラスの使用については、MSDNページからほぼ逐語的に構文をコピーしたと確信しています。コードは次のとおりです。
// VideoInfoAssembly.cpp
// compile with: /clr
using namespace std;
using namespace System;
using namespace System::Runtime::InteropServices;
#include "stdafx.h"
#include "VideoInfoAssembly.h"
#pragma managed
namespace VideoInfoAssembly
{
short VideoInfo::GetWidth(System::String^ managedString)
{
// Marshal the managed string to unmanaged memory.
char* stringPointer = (char*) Marshal::StringToHGlobalAnsi(managedString).ToPointer();
// Always free the unmanaged string.
Marshal::FreeHGlobal(IntPtr(stringPointer));
return 9001;
}
}
大まかに言えば、ビデオファイルのビデオプロパティを読み取る必要があるC#アプリがあり、MicrosoftMediaFoundationにはC++が必要です。DLLを正常に構築し、テストとして9000を超える値を返すようにしました。今、私は管理された文字列をDLL(ビデオファイル名になります)に渡そうとしています。しかし、私はマーシャルクラスを機能させるために1時間以上苦労してきました。前に述べたように、私はMSDNページを使用して成功していません。私は何が欠けていますか?