Where is My.Settings?

  • Thread starter Thread starter eBob.com
  • Start date Start date
E

eBob.com

When I execute the following lines of code ...

Dim clients(My.Settings.Clients.Count) As String
My.Settings.Clients.CopyTo(clients, 0)
combxClients.Items.AddRange(clients)

.... the last statement throws an exception, "Value cannot be null.
Parameter name:item". This is apparently because I have a null value in
My.Settings.Clients (Type: System.Collection / Scope: User). I think I know
how that happened and will fix the code so that it doesn't happen again.
BUT ... how do I fix the problem I have at the moment? I think that I can
simply edit the settings file but I can't find it. If it matters this is a
Vistax64 system with VS 2008.

Thanks, Bob
 
When I execute the following lines of code ...

Dim clients(My.Settings.Clients.Count) As String
My.Settings.Clients.CopyTo(clients, 0)
combxClients.Items.AddRange(clients)

... the last statement throws an exception, "Value cannot be null.
Parameter name:item". This is apparently because I have a null value in
My.Settings.Clients (Type: System.Collection / Scope: User). I think I
know how that happened and will fix the code so that it doesn't happen
again. BUT ... how do I fix the problem I have at the moment? I think
that I can simply edit the settings file but I can't find it. If it
matters this is a Vistax64 system with VS 2008.

Thanks, Bob

This article shows you how to find it:
http://www.codeproject.com/KB/vb/appsettings2005.aspx. Hope this helps.
 
Thank you FTM. I should have added in my original post that I tried to look
in some directories which seemed like likely candidates but ran into "Access
is denied" problems. I guess I was hoping that My.Settings lived somewhere
where I wouldn't have Access denied problems. But that is what is happening
when I try to follow the directions in the reference you gave me. And I am
logged on to an account with Admin authority and have even turned off UAC.
Well ... not a problem for this newsgroup I guess. Thanks, Bob
 
Write a small piece of code in startup that sets the My.Settings value to a
valid object, and saves it. Then run your app, then comment out the code.
Presumably, once your program runs the correct valid value will be written
to the variable and the problem won't recur, but for now you just need to
get something vald into teh file.

If you want to synchronise your settings you will have to find out what a
valid value is so that you can insert it as the default value for the
swetting, so even if you do edit the file, do the bit of code as above to
set a valid value into the settings and save it before you try to edit the
file - otherwise there is no simple way to work out what the edit is that
you need to do. Once you see what the required string is, insert it as the
default value.

It will be something like this:

<?xml version="1.0" encoding="utf-16"?>
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<string>Client Option 1</string>
</ArrayOfString>
 
Back
Top