This project is read-only.

Constructor on type 'System.String' not found

Feb 7, 2012 at 7:14 PM

Hello again,

I am currently building my toolbox, and the minute I go to set the ToolDirectories path to "Tools"(By clicking "Add"), it spits the error in the title.

Is there any way around this?

Thanks,

Logan 

Feb 7, 2012 at 9:04 PM
Edited Feb 7, 2012 at 9:04 PM

What is the error? Are you using version 1.0?

Feb 7, 2012 at 9:17 PM
Edited Feb 7, 2012 at 11:36 PM

The error is "Constructor on type 'System.String' not found." Yes, I am using 1.0.

 

Edit: If the Directories property for the AppManager is set (so extensions aren't null), it does the same exact thing.


 

Edit 2: Since the directories in AppManager are null, I keep getting an ArgumentNullException. The IEnumerable GetDirectortiesNestedOneLevel() does not allow for values to be null.

I guess the fix for this would be adding this line before "foreach (string directory in Directories.Union(new[] { "Data Extensions", "Tools" }))"


 if (Directories == null) { Directories = new List<string>().ToArray(); }


 

 

Feb 8, 2012 at 5:51 PM

I though the fix for this should be decorating the property declaration with this:

 


 

[Editor("System.Windows.Forms.Design.StringCollectionEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.Drawing.Design.UITypeEditor))]


But I guess I was wrong... Any more information on this?

Feb 8, 2012 at 5:57 PM

Why or where does Directories get set to null? Shouldn't we consider throwing an exception in the setter instead of checking everywhere to see if it is null?

Note this line of code in the constructor sets the property:

Directories = new List<string> { "Application Extensions""Plugins" };
Feb 8, 2012 at 7:13 PM

It is not that it is set to null in code. Something is going wrong when the directories are set in the properties windows. This is when "Constructor on type 'System.String' not found" happens. Because of this, the directories are not set in the property grid, causing them to come back null. 

This leads me to believe that when public List<string> Directories { get; set;} is called, it is not allowing for the built-in string collection editor to come into instance, and then causing this error. Please note this is in Public Properties region within AppManager.cs.

I may be missing something at this moment in time, but these errors are pointing to this conclusion. I think to fix the original error "Constructor on type 'System.String' not found", when setting either AppManager Directories, or ToolDirectories, will fix the ArgumentNullException.


Feb 9, 2012 at 1:02 AM
Edited Feb 9, 2012 at 1:03 AM

Ok, I see where you are headed now. It looks like 

[Editor("System.Windows.Forms.Design.ListControlStringCollectionEditor, System.Design"typeof(System.Drawing.Design.UITypeEditor))]

should work according to the comments on http://msdn.microsoft.com/en-us/library/42737xf2(v=vs.80).aspx

Do you want to check this and let us know?

Feb 9, 2012 at 1:04 AM

If that doesn't work, we might look into adapting Chris's code at http://dotspatial.codeplex.com/discussions/273201

Feb 9, 2012 at 4:09 AM

Mudnug,

I will definitely let you know the outcome. I believe we may need to implement something such as this:

private List<String> appDirectoriesList;

 

[Editor("System.Windows.Forms.Design.StringCollectionEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(System.Drawing.Design.UITypeEditor))]

public List<String> Directories List {

get { return appDirectoriesList; }

set { ;}

}

 

public appManagerListTest()

{

InitializeComponent();

appDirectoriesList = new List<String>();

}

 

protected override void OnPaint(PaintEventArgs pe)

{

base.OnPaint(pe);

}

Feb 9, 2012 at 7:13 PM
Edited Feb 10, 2012 at 9:31 PM

Are you seeing this problem in DemoMap?

I'm able to select the appManager and add Directories without trouble.

Feb 9, 2012 at 10:14 PM

I am. That is the weird part. I assumed that if I used an example, things would work smoothly. But, quite the contrary.

Feb 10, 2012 at 9:32 PM

Hmm, Let me know if you come up with a way to reproduce the problem...