D
Dick Swager
Guest
The following C++/CLI code works fine in VS2015 but when I migrated it to VS2019 I get the error "use of this type requires a reference to assembly" refering to the statement "server == nullptr". I realize that C++/CLI has its own nullptr but I tried using std::nullpptr and nullptr_t and still get the error when compiling.
So has the compiler tightened up the use of nullptr and if so what is the right syntax for doing what I need to do? Or did I fail to install some component during the installation of VS2019 and if so, what component?
#include "stdafx.h"
using namespace System;
using namespace Microsoft::SqlServer::Management::Smo;
public ref class SomeThing
{
static Server^ server = nullptr;
static String^ serverName = "";
void ConnectToServer ()
{
// Connect to the local, default instance of SQL Server
// unless the connection has already been made.
if (server == nullptr)
{
server = gcnew Server ();
serverName = server->Name;
}
}
public:
SomeThing () { ConnectToServer (); }
String^ GetServerName () { return serverName; }
};
int main(array<System::String ^> ^args)
{
SomeThing^ someThing = gcnew SomeThing ();
Console::WriteLine (someThing->GetServerName ());
return 0;
}
Thanks, Dick
Continue reading...
So has the compiler tightened up the use of nullptr and if so what is the right syntax for doing what I need to do? Or did I fail to install some component during the installation of VS2019 and if so, what component?
#include "stdafx.h"
using namespace System;
using namespace Microsoft::SqlServer::Management::Smo;
public ref class SomeThing
{
static Server^ server = nullptr;
static String^ serverName = "";
void ConnectToServer ()
{
// Connect to the local, default instance of SQL Server
// unless the connection has already been made.
if (server == nullptr)
{
server = gcnew Server ();
serverName = server->Name;
}
}
public:
SomeThing () { ConnectToServer (); }
String^ GetServerName () { return serverName; }
};
int main(array<System::String ^> ^args)
{
SomeThing^ someThing = gcnew SomeThing ();
Console::WriteLine (someThing->GetServerName ());
return 0;
}
Thanks, Dick
Continue reading...