MySQL 6.9.8 - System.String.Substring exception when opening new connection












1















Every now and then, when I'm making a database query I run into a problem with ExecuteNonQuery in the MySQL.Data library.



enter image description here



The exception which gets raised is this:



Exception thrown: 'System.ArgumentOutOfRangeException' in CommonLanguageRuntimeLibrary ("Length cannot be less than zero.")



There are my logs from IntelliTrace from an Azure Worker Role.



It works most of the time but when this happens it stops the normal processing of the worker.



I'm loading the connection string from app.config, this is what it looks like:



<add key="DatabaseConnectionString" value="Server=localhost; Port=3306; Uid=user; Pwd=mypassword; Pooling=false;" />



I select the database at runtime with every request because it keeps changing which database it's connecting to.



Is there anything I can do to stop this from occurring and allow the new connection to open correctly?



Edit



Upon further investigation and crawling through the MySQL.Data Source code I've drilled down into this getter.



    [DisplayName("program_name")]
public string ProgramName
{
get
{
string name = Environment.CommandLine;
try
{
string path = Environment.CommandLine.Substring(0, Environment.CommandLine.IndexOf("" ")).Trim('"');
name = System.IO.Path.GetFileName(path);
if (Assembly.GetEntryAssembly() != null)
name = Assembly.GetEntryAssembly().ManifestModule.Name;
}
catch (Exception ex)
{
name = string.Empty;
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
return name;
}
}


Now is it possible that the WorkerRole will start returning a different value for the Environment.CommandLine property sometime during the execution? That's what seems to be happening because it works at the beginning and then fails after a while (2-3 days.)










share|improve this question

























  • Please post the code snippet that contains the Substring method.

    – Wicher Visser
    Jun 2 '16 at 11:29











  • It's internal inside the MySQL.Data library. It's not my code, it's the actual MySQL code. The image shows the trace of how deep it got from me calling ExecuteNonQuery to all the internal methods where it crashed at the bottom

    – Daniel Wardin
    Jun 2 '16 at 11:36











  • Can you reproduce this with actual data?

    – Wicher Visser
    Jun 2 '16 at 11:42











  • It's random, happens once every 2-3 days. Sometimes more often. It only ever does this on ExecuteNonQuery call and not ExectueQuery which I find weird

    – Daniel Wardin
    Jun 2 '16 at 11:46











  • It may try to "substring" an empty string or null value. You will have to have a reproduction dataset.

    – Wicher Visser
    Jun 2 '16 at 11:54
















1















Every now and then, when I'm making a database query I run into a problem with ExecuteNonQuery in the MySQL.Data library.



enter image description here



The exception which gets raised is this:



Exception thrown: 'System.ArgumentOutOfRangeException' in CommonLanguageRuntimeLibrary ("Length cannot be less than zero.")



There are my logs from IntelliTrace from an Azure Worker Role.



It works most of the time but when this happens it stops the normal processing of the worker.



I'm loading the connection string from app.config, this is what it looks like:



<add key="DatabaseConnectionString" value="Server=localhost; Port=3306; Uid=user; Pwd=mypassword; Pooling=false;" />



I select the database at runtime with every request because it keeps changing which database it's connecting to.



Is there anything I can do to stop this from occurring and allow the new connection to open correctly?



Edit



Upon further investigation and crawling through the MySQL.Data Source code I've drilled down into this getter.



    [DisplayName("program_name")]
public string ProgramName
{
get
{
string name = Environment.CommandLine;
try
{
string path = Environment.CommandLine.Substring(0, Environment.CommandLine.IndexOf("" ")).Trim('"');
name = System.IO.Path.GetFileName(path);
if (Assembly.GetEntryAssembly() != null)
name = Assembly.GetEntryAssembly().ManifestModule.Name;
}
catch (Exception ex)
{
name = string.Empty;
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
return name;
}
}


Now is it possible that the WorkerRole will start returning a different value for the Environment.CommandLine property sometime during the execution? That's what seems to be happening because it works at the beginning and then fails after a while (2-3 days.)










share|improve this question

























  • Please post the code snippet that contains the Substring method.

    – Wicher Visser
    Jun 2 '16 at 11:29











  • It's internal inside the MySQL.Data library. It's not my code, it's the actual MySQL code. The image shows the trace of how deep it got from me calling ExecuteNonQuery to all the internal methods where it crashed at the bottom

    – Daniel Wardin
    Jun 2 '16 at 11:36











  • Can you reproduce this with actual data?

    – Wicher Visser
    Jun 2 '16 at 11:42











  • It's random, happens once every 2-3 days. Sometimes more often. It only ever does this on ExecuteNonQuery call and not ExectueQuery which I find weird

    – Daniel Wardin
    Jun 2 '16 at 11:46











  • It may try to "substring" an empty string or null value. You will have to have a reproduction dataset.

    – Wicher Visser
    Jun 2 '16 at 11:54














1












1








1








Every now and then, when I'm making a database query I run into a problem with ExecuteNonQuery in the MySQL.Data library.



enter image description here



The exception which gets raised is this:



Exception thrown: 'System.ArgumentOutOfRangeException' in CommonLanguageRuntimeLibrary ("Length cannot be less than zero.")



There are my logs from IntelliTrace from an Azure Worker Role.



It works most of the time but when this happens it stops the normal processing of the worker.



I'm loading the connection string from app.config, this is what it looks like:



<add key="DatabaseConnectionString" value="Server=localhost; Port=3306; Uid=user; Pwd=mypassword; Pooling=false;" />



I select the database at runtime with every request because it keeps changing which database it's connecting to.



Is there anything I can do to stop this from occurring and allow the new connection to open correctly?



Edit



Upon further investigation and crawling through the MySQL.Data Source code I've drilled down into this getter.



    [DisplayName("program_name")]
public string ProgramName
{
get
{
string name = Environment.CommandLine;
try
{
string path = Environment.CommandLine.Substring(0, Environment.CommandLine.IndexOf("" ")).Trim('"');
name = System.IO.Path.GetFileName(path);
if (Assembly.GetEntryAssembly() != null)
name = Assembly.GetEntryAssembly().ManifestModule.Name;
}
catch (Exception ex)
{
name = string.Empty;
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
return name;
}
}


Now is it possible that the WorkerRole will start returning a different value for the Environment.CommandLine property sometime during the execution? That's what seems to be happening because it works at the beginning and then fails after a while (2-3 days.)










share|improve this question
















Every now and then, when I'm making a database query I run into a problem with ExecuteNonQuery in the MySQL.Data library.



enter image description here



The exception which gets raised is this:



Exception thrown: 'System.ArgumentOutOfRangeException' in CommonLanguageRuntimeLibrary ("Length cannot be less than zero.")



There are my logs from IntelliTrace from an Azure Worker Role.



It works most of the time but when this happens it stops the normal processing of the worker.



I'm loading the connection string from app.config, this is what it looks like:



<add key="DatabaseConnectionString" value="Server=localhost; Port=3306; Uid=user; Pwd=mypassword; Pooling=false;" />



I select the database at runtime with every request because it keeps changing which database it's connecting to.



Is there anything I can do to stop this from occurring and allow the new connection to open correctly?



Edit



Upon further investigation and crawling through the MySQL.Data Source code I've drilled down into this getter.



    [DisplayName("program_name")]
public string ProgramName
{
get
{
string name = Environment.CommandLine;
try
{
string path = Environment.CommandLine.Substring(0, Environment.CommandLine.IndexOf("" ")).Trim('"');
name = System.IO.Path.GetFileName(path);
if (Assembly.GetEntryAssembly() != null)
name = Assembly.GetEntryAssembly().ManifestModule.Name;
}
catch (Exception ex)
{
name = string.Empty;
System.Diagnostics.Debug.WriteLine(ex.ToString());
}
return name;
}
}


Now is it possible that the WorkerRole will start returning a different value for the Environment.CommandLine property sometime during the execution? That's what seems to be happening because it works at the beginning and then fails after a while (2-3 days.)







c# mysql azure azure-worker-roles mysql.data






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 2 at 3:46









Cœur

19k9112154




19k9112154










asked Jun 2 '16 at 11:22









Daniel WardinDaniel Wardin

1,2571739




1,2571739













  • Please post the code snippet that contains the Substring method.

    – Wicher Visser
    Jun 2 '16 at 11:29











  • It's internal inside the MySQL.Data library. It's not my code, it's the actual MySQL code. The image shows the trace of how deep it got from me calling ExecuteNonQuery to all the internal methods where it crashed at the bottom

    – Daniel Wardin
    Jun 2 '16 at 11:36











  • Can you reproduce this with actual data?

    – Wicher Visser
    Jun 2 '16 at 11:42











  • It's random, happens once every 2-3 days. Sometimes more often. It only ever does this on ExecuteNonQuery call and not ExectueQuery which I find weird

    – Daniel Wardin
    Jun 2 '16 at 11:46











  • It may try to "substring" an empty string or null value. You will have to have a reproduction dataset.

    – Wicher Visser
    Jun 2 '16 at 11:54



















  • Please post the code snippet that contains the Substring method.

    – Wicher Visser
    Jun 2 '16 at 11:29











  • It's internal inside the MySQL.Data library. It's not my code, it's the actual MySQL code. The image shows the trace of how deep it got from me calling ExecuteNonQuery to all the internal methods where it crashed at the bottom

    – Daniel Wardin
    Jun 2 '16 at 11:36











  • Can you reproduce this with actual data?

    – Wicher Visser
    Jun 2 '16 at 11:42











  • It's random, happens once every 2-3 days. Sometimes more often. It only ever does this on ExecuteNonQuery call and not ExectueQuery which I find weird

    – Daniel Wardin
    Jun 2 '16 at 11:46











  • It may try to "substring" an empty string or null value. You will have to have a reproduction dataset.

    – Wicher Visser
    Jun 2 '16 at 11:54

















Please post the code snippet that contains the Substring method.

– Wicher Visser
Jun 2 '16 at 11:29





Please post the code snippet that contains the Substring method.

– Wicher Visser
Jun 2 '16 at 11:29













It's internal inside the MySQL.Data library. It's not my code, it's the actual MySQL code. The image shows the trace of how deep it got from me calling ExecuteNonQuery to all the internal methods where it crashed at the bottom

– Daniel Wardin
Jun 2 '16 at 11:36





It's internal inside the MySQL.Data library. It's not my code, it's the actual MySQL code. The image shows the trace of how deep it got from me calling ExecuteNonQuery to all the internal methods where it crashed at the bottom

– Daniel Wardin
Jun 2 '16 at 11:36













Can you reproduce this with actual data?

– Wicher Visser
Jun 2 '16 at 11:42





Can you reproduce this with actual data?

– Wicher Visser
Jun 2 '16 at 11:42













It's random, happens once every 2-3 days. Sometimes more often. It only ever does this on ExecuteNonQuery call and not ExectueQuery which I find weird

– Daniel Wardin
Jun 2 '16 at 11:46





It's random, happens once every 2-3 days. Sometimes more often. It only ever does this on ExecuteNonQuery call and not ExectueQuery which I find weird

– Daniel Wardin
Jun 2 '16 at 11:46













It may try to "substring" an empty string or null value. You will have to have a reproduction dataset.

– Wicher Visser
Jun 2 '16 at 11:54





It may try to "substring" an empty string or null value. You will have to have a reproduction dataset.

– Wicher Visser
Jun 2 '16 at 11:54












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f37590416%2fmysql-6-9-8-system-string-substring-exception-when-opening-new-connection%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f37590416%2fmysql-6-9-8-system-string-substring-exception-when-opening-new-connection%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

MongoDB - Not Authorized To Execute Command

in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

How to fix TextFormField cause rebuild widget in Flutter