VS 2012 で適切にコンパイルされる CLR 用の VC++ プロジェクトがあります。ただし、実行時に次の例外が発生します。
「アセンブリ 'mscorlib、Version=4.0.0.0、Culture=neutral、PublicKeyToken=b77a5c561934e089' から型 'System.Int32[]&' を読み込めませんでした」
コードは次のとおりです。
// ClassLibrary1.h
#pragma once
using namespace System;
using namespace System::Runtime::InteropServices;
namespace ClassLibrary1 {
//template <typename T>
class ArgOutValueArray
{
public:
ArgOutValueArray(int (__gc* __nogc& aRef) __gc[] )
{
//(*x)[0] = 100;
}
};
public __gc class Class1
{
public:
static void f1([Out] int (*x) __gc[])
{
f2(x);
}
static void f2([Out] int (*x) __gc[])
{
ArgOutValueArray arg_xeqp(x); // Getting the exception at this line.
}
};
}