Hi in the second line while trying to convert from object to String array it shows compile time error as
'System::String ^' : a native array cannot contain this managed type
'initializing' : cannot convert from 'System::String ^' to 'System::String ^[]'
code:
RegistryKey ^rk = Registry::LocalMachine->OpenSubKey("SOFTWARE\\Microsoft\\Microsoft SQLServer");
String ^instances[] = (String^)rk->GetValue("InstalledInstances");
How to fix this .... Thanks in advance.
From stackoverflow
-
Change the last line to
String ^ instances = (String^)rk->GetValue("InstalledInstances");(note the absence of brackets). If the key contains a multistring, use
array<String^>^ instances = (array<String^>^)rk->GetValue("InstalledInstances");See the documentation for RegistryKey.GetValue for more information.
-
You declared
instancesas an array type:String ^instances[] = (String^)rk->GetValue("InstalledInstances");Instead, declare it as a string:
String ^instances = (String^)rk->GetValue("InstalledInstances");
0 comments:
Post a Comment