I am getting a C++/CLI array type is not allowed here error when using array type in a class. First I have created a Console application in Visual Studio 2013 and added a new class "MainClass". Then I added a new method. The thing is that I used array in the same project in the main cpp file with no classes with no problems and it seems like it's being used the same way in this example. Here's MainClass.h:
#pragma once
#using <System.dll>
#using <System.Security.dll>
#include <windows.h>
using namespace System;
using namespace System::Security;
using namespace System::Security::Cryptography;
using namespace System::Security::Cryptography::X509Certificates;
using namespace System::IO;
using namespace System::Collections::Generic;
ref class MainClass
{
public:
MainClass();
bool Verify(array<System::Byte> DataToVerify);
};
MainClass.cpp:
#include "MainClass.h"
#using <System.dll>
#using <System.Security.dll>
#include <windows.h>
using namespace System;
using namespace System::Security;
using namespace System::Security::Cryptography;
using namespace System::Security::Cryptography::X509Certificates;
using namespace System::IO;
using namespace System::Collections::Generic;
MainClass::MainClass()
{
}
bool MainClass::Verify(array<System::Byte> DataToVerify)
{
return false;
}
bool Verify(array<System::Byte> DataToVerify);
Knowing when to use the ^ hat is super-duper important in C++/CLI. And compile errors not exactly fantastic when you don't use it properly. Arrays are reference types, omitting the hat is not optional here when you pass the array as an argument. It is in fact never optional, stack semantics on managed arrays doesn't make sense since they are not disposable. Fix:
bool Verify(array<System::Byte>^ DataToVerify);
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments