Reputation: 35
I am trying to create a launcher for the game "Minecraft" , and I use a library. So basically I am trying to add values into a combo box from a list , but it gives me a error:
Argument 1: cannot convert from 'string' to 'object[]
This is my code:
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using CmlLib.Core;
using CmlLib.Core.Auth;
namespace cosmic_cord_installer
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
var path = new MinecraftPath();
var launcher = new CMLauncher(path);
var versions = launcher.GetAllVersions();
foreach (var item in versions)
{
comboBox1.Items.AddRange(item.Name);
}
}
private async void bunifuButton1_Click_1(object sender, EventArgs e)
{
System.Net.ServicePointManager.DefaultConnectionLimit = 256;
var path = new MinecraftPath();
var launcher = new CMLauncher(path);
var versions = await launcher.GetAllVersionsAsync();
foreach (var item in versions)
{
Console.WriteLine(item.Name);
}
var launchOption = new MLaunchOption
{
MaximumRamMb = 4096,
Session = MSession.GetOfflineSession("hello"), // Login Session. ex) Session = MSession.GetOfflineSession("hello")
VersionType = "CosmicLauncher",
GameLauncherName = "CosmicLauncher",
GameLauncherVersion = "2",
};
var process = await launcher.CreateProcessAsync("1.12.2", launchOption); // vanilla
// var process = await launcher.CreateProcessAsync("1.12.2-forge1.12.2-14.23.5.2838", launchOption); // forge
// var process = await launcher.CreateProcessAsync("1.12.2-LiteLoader1.12.2"); // liteloader
// var process = await launcher.CreateProcessAsync("fabric-loader-0.11.3-1.16.5") // fabric-loader
process.Start();
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void bunifuButton2_Click(object sender, EventArgs e)
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/C explorer %appdata%\\.minecraft";
process.StartInfo = startInfo;
process.Start();
}
}
}
This is the line with the error:
comboBox1.Items.AddRange(item.Name);
How would I add the values in another way , or how would I fix this error?
Upvotes: 1
Views: 82