Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8350631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:22:25+00:00 2026-06-09T08:22:25+00:00

On line 69 I am getting the error ArgumentOutOfRangeException was unhandled. /* Please critique

  • 0

On line 69 I am getting the error “ArgumentOutOfRangeException was unhandled”.

/*
Please critique as I'm always looking for ways to improve my coding.

Usage Example:
MapleWebStart mws = new MapleWebStart("myusername", "mypassword");
mws.Start();
*/

using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Text;
using Microsoft.Win32;

public class MapleWebStart
{
    private CookieContainer LoginCookie;

    public MapleWebStart(string username, string password)
    {
        LoginCookie = new CookieContainer();
        if (!Login(username, password))
            throw new ArgumentException("Invalid Nexon username or password.");
    }

    public MapleWebStart(CookieContainer loginCookie)
    {
        LoginCookie = loginCookie;
    }

    private bool Login(string username, string password)
    {
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://maplestory.nexon.net/Controls/Passport.aspx");
        request.Method = "POST";
        string postData = "__VIEWSTATE=%2FwEPDwULLTE5NjM3MjM3MDcPZBYCAgMPZBYEAgUPFgIeB1Zpc2libGVoZAIHDxYCHwBoZGSVGoua1TAiCeQWNk%2BdqOF%2FXtq%2BmA%3D%3D&tbID=" + username + "&" + "tbPass=" + password;
        byte[] byteArray = Encoding.UTF8.GetBytes(postData);
        request.CookieContainer = LoginCookie;
        request.ContentType = "application/x-www-form-urlencoded";
        request.ContentLength = byteArray.Length;
        Stream dataStream = request.GetRequestStream();
        dataStream.Write(byteArray, 0, byteArray.Length);
        dataStream.Close();
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        dataStream = response.GetResponseStream();
        StreamReader reader = new StreamReader(dataStream);
        string responseFromServer = reader.ReadToEnd();
        reader.Close();
        dataStream.Close();
        response.Close();
        if (!responseFromServer.Contains("Wrong password"))
        {
            LoginCookie.Add(response.Cookies);
            return true;
        }
        return false;
    }

    private string GetMaplePath()
    {
        string maplePath = (string)Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Wizet\MapleStory", "ExecPath", "");
        return File.Exists(maplePath) ? maplePath : (string)Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Wizet\MapleStory", "ExecPath", "");
    }

    public void Start()
    {
        ProcessStartInfo maplestory = new ProcessStartInfo();
        maplestory.FileName = GetMaplePath() + @"\MapleStory.exe";
        maplestory.Arguments = "WebStart " + LoginCookie.GetCookies(new Uri("http://nexon.net"))[0].ToString().Substring(4);
        Process.Start(maplestory);
    }

original code: http://pastie.org/private/vgpxht8tehtdjml2jdq

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T08:22:26+00:00Added an answer on June 9, 2026 at 8:22 am

    Your problem is that

    LoginCookie.GetCookies(new Uri("http://nexon.net"))[0].ToString()
    

    returns a string with less than 5 characters. So, doing

    LoginCookie.GetCookies(new Uri("http://nexon.net"))[0].ToString().Substring(4)
    

    will fail, since there will be no character at position 4. You have to check the string length before dealing with it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi can someone please tell me what wrong with this line (getting an error...)
I am getting ERROR when I am running this program at the line static
I am getting an error at the line void operation when I compile, because
I am keep getting NullPointerException error at line JSONObject json = userFunctions.uploadFileData(guid, photoName); in
I keep getting this error in the $('#savetickets-list') line. I want to dynamically add
I am getting an error Incorrect syntax near ',' for this query on line
I'm getting an error of a NullPointerException and it is referencing the line Camera.Parameters:
I am getting this error: Data at the root level is invalid. Line 1,
Visual Studio c++ 2005 I am getting an error on the last line of
I'm getting a compiler error for this line: Collections.sort(terms, new QuerySorter_TFmaxIDF(myInteger)); My customized Comparator

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.