Error on Project Settings “An error occurred while reading the app.config file” when using configSource

Error: on opening Project > Settings
“An error occurred while reading the app.config file. The file might be corrupted or contain invalid XML”
However all functionality works

Occurs when using
<connectionStrings configSource=SharedApp.config></connectionStrings>

Solution: Unknown

LINQ and Entity Framework binding to ComboBox and DataGridViewComboBox

Private context As BC.SWT.EntityModel.SOPEntities

Private Sub LoadLookupData()


    Dim EntityConnectionString = Configuration.ConfigurationManager.ConnectionStrings(“SOPEntities”).ConnectionString
    context = New BC.SWT.EntityModel.SOPEntities(EntityConnectionString)

    Dim CustomerQuery As ObjectQuery(Of Customer) = context.Customers
    ‘CustomerIDComboBox.DataSource = CustomerQuery.Execute(MergeOption.AppendOnly) ‘works but includes all columns
    Dim results = From a In CustomerQuery Select a.CustomerID, a.Customer1 Order By Customer1
    CustomerIDComboBox.DataSource = results
    CustomerIDComboBox.DisplayMember = “Customer1”

    CustomerIDDataGridViewComboBoxColumn.DataSource = results.ToList
    CustomerIDDataGridViewComboBoxColumn.DisplayMember = “Customer1”
    CustomerIDDataGridViewComboBoxColumn.ValueMember = “CustomerID”
    CustomerIDDataGridViewComboBoxColumn.DataPropertyName = “CustomerID”

Catch ex As Exception
    MessageBox.Show(ex.Message, Me.Text)
End Try

End Sub

How to use “external” configuration files e.g. SharedApp.config with a test project?

Test method TestProjectBusiness.dsBusinessHelperTest.FillAdviceNoteTest threw exception:
System.Configuration.ConfigurationErrorsException: Unable to open configSource file ‘SharedApp.config’. (…Visual Studio 2010\Projects\…\TestResults\…\Out\TestProject.DLL.config line 8)

Solution at:

“If you edit the test run configuration (by double clicking the .testrunconfig file that gets put into the ‘Solution Items’ solution folder when you add a new unit test), you get a test run configuration dialog. There’s a section there called ‘Deployment’ where you can specifiy files or whole folders from anywhere in the solution that can be copied out with the compiled assemblies at run time to the correct folder.

In this way, I can now actually just define most of my configuration in one set of external .config files and have them automatically copied out at the run of each test.”

My Notes:
This works. You may have to close and re-open the test run – test list editor .vsmdi for the appropriate test-settings to take affect.

Some of the properties associated with the solution could not be read

Visual Studio when opening a solution.
“One or more projects were not loaded correctly”
“Some of the properties associated with the solution could not be read”

Following did not work really, but does discuss the corrupt solution file, which may have a different number of projects to those attached to this solution.

Alternative is to create a new solution and add the projects to it.

Also am finding that Windows 7 machine, moving to XP machine, is making XP machine files read-only. This may be part of the problem.

WPF RichTextBox: How To Load, Edit and Save Rich Text Format

See Ged Mead

WPF RichTextBox : How to Load and Save Plain Text Content

See Ged Mead

XML. Get from SQL. Dataset.ReadXML(filePath) Publish

How do I get XML data from an SQL Select statement

SELECT [ID],[Name],[Notes],[Example],[DateInput] FROM [SystemDesign].[dbo].[Connections]
FOR XML PATH(‘Connection’), ROOT(‘Connections’)

The output could be copied into a new XML file in Visual Studio

How do I read XML data into a DataSet

Dim filePath = String.Concat(My.Application.Info.DirectoryPath, “\XMLData\Connections.xml”)
Dim filePathSchema = String.Concat(My.Application.Info.DirectoryPath, “\XMLData\Connections.xsd”)
Using ds As New DataSet
End Using

How do I distribute and Publish the MyFile.xml and MyFile.xsd

Make sure that on the properties of both these files that:
“Build Action” = “Content”
“Copy to Output Directory” is “Copy if Newer” or “Copy Always”
On Project > Properties > Publish > Application Files > Find <FileName>.xml file and set Publish Status to “Include”

What other considerations are there?

Dataset.ReadXMLSchema(filepath) normally first
Otherwise Dataset.ReadXML will return a table, but the columns are probably of the wrong datatype
So in the above example, the merge will not work because the strongly type dsObjectControl.Connections uses a proper schema.

For the same reason if you hard-code bind the newly created ds.Tables(0) to a bindingsource, this may not work if the schema is important.

How do I get an xsd file?

There is a tool in Visual Studio on Add new item > Data > XML to Schema

How do I validate my xml file against a xsd file?

Possible by adding . See Toolkit.sln. Also links here:

How do I get my new dataset to hold the schema from the xml file

TODO currently only by using the Dataset.ReadXMLSchema(filepath) as listed above. It does not get it right on it’s own.

How do I convert my xsd file into a dataset

Was able to do this, mostly by opening it. Also by adding the Custom Tool.

“Changes to 64-bit applications is not allowed” when attempting to edit code at run-time

If this is holding you back then try:
> Project Properties > Compile > Advanced Compile Options > Target CPU: change to x86