I am updating an old application built several years ago and the global namespace and, project.cs file, and the main form were all named as email2case_winForm
I wanted to change this (alongside rebuilding the application in more of an OOP way to make it more flexible, and to be able to re-use code), so changed the names to email2case
But now I am having trouble compiling because when reading the settings and properties of the project, those members cannot be found.
Here is an example of the code I am trying to use to read the properties.Settings:
XElement x = XElement.Load(email2case.Properties.Settings.Default.e2cConfigFile);
and the compiler error for that one is:
'email2case.email2case' does not contain a definition for 'Properties'
Here is how a class is reading from the global settings:
this.Url = global::email2case.Settings.Default.email2case_sforce_SforceService;
and the compiler error for that one is:
The type or namespace name 'Settings' does not exist in the namespace 'email2case' (are you missing an assembly reference?)
I have a hunch that the problem is caused by the definitions in app.Config
and here it is:
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="email2case.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
<section name="email2case.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="email2case.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<email2case.Properties.Settings>
<setting name="email2case_sforce_SforceService" serializeAs="String">
<value>https://login.salesforce.com/servi...</value>
</setting>
<setting name="e2cConfigFile" serializeAs="String">
<value>C:\email2case\data\e2cConfig.xml</value>
</setting>
</email2case.Properties.Settings>
<email2case.Properties.Settings>
<setting name="email2case_sforce_SforceService" serializeAs="String">
<value>https://login.salesforce.com/serv...</value>
</setting>
</email2case.Properties.Settings>
</applicationSettings>
<system.serviceModel>
<bindings/>
<client/>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup><userSettings>
<email2case.email2case.Properties.Settings>
<setting name="enableEWSTrace" serializeAs="String">
<value>False</value>
</setting>
<setting name="attachmentsPathLocal" serializeAs="String">
<value>C:\email2case\temp\</value>
</setting>
<setting name="eTracePath" serializeAs="String">
<value>C:\email2case\Trace\</value>
</setting>
<setting name="ewsTraceKeepDays" serializeAs="String">
<value>1</value>
</setting>
</email2case.email2case.Properties.Settings>
</userSettings>
</configuration>
I don't want to go editing that without knowing exactly the right way to do it, so what code should I use to reference my properties and settings?
Or should I alter the way they are defined in the app.config?
The issue was caused by 2 problems:
old namespace
with new namespace
The solution was to
Properties.
and NOT email2case.Properties.
... If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With