Bug 41240 - Invalid IL code in System.Configuration.ConfigurationManager:get_AppSettings (): method body is empty.
Summary: Invalid IL code in System.Configuration.ConfigurationManager:get_AppSettings ...
Status: RESOLVED NORESPONSE
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler (show other bugs)
Version: 6.0.0
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2016-05-22 20:46 UTC by Alex Koon
Modified: 2017-10-04 16:01 UTC (History)
3 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Screen shoot error (104.49 KB, image/jpeg)
2016-11-11 13:54 UTC, André
Details

Description Alex Koon 2016-05-22 20:46:11 UTC
Invalid IL code in System.Configuration.ConfigurationManager:get_AppSettings (): method body is empty.

When trying to retrieve an app setting from app.config. The key I am looking for is present in the file. Why is this happening? 

MonoAndroid 6.0.0
Visual Studio Community 15 with Xamarin
Windows 10 Pro

<configuration>
<appSettings>
<add key="key" value="value"
</appSettings>
</configuration>

I.E. 
using System.Configuration;
string key = ConfigurationManager.AppSettings["key"];


The steps to reproduce this are trivial. Enter the appSetting in the app.config and try to extract the value in the code. What is going on here? I get the same error if I try doing this.

Configuration config = ConfigurationManager.OpenExeConfiguration(path to file);
Comment 1 Jonathan Pryor 2016-05-22 21:55:06 UTC
Are you sure you're using Xamarin.Android? Xamarin.Android does not provide System.Configuration.ConfigurationManager, and the only included types in the v1.0 framework directory -- e.g. mscorlib.dll, System.dll -- are:

System.Web.Services.dll:
> System.Web.Services.Configuration.XmlFormatExtensionAttribute
> System.Web.Services.Configuration.XmlFormatExtensionPointAttribute
> System.Web.Services.Configuration.XmlFormatExtensionPrefixAttribute

System.Xml.dll:
> System.Xml.XmlConfiguration.XmlReaderSection
> System.Xml.XmlConfiguration.XsltConfigSection

mscorlib.dll:
> System.Configuration.Assemblies.AssemblyHash
> System.Configuration.Assemblies.AssemblyHashAlgorithm
> System.Configuration.Assemblies.AssemblyVersionCompatibility
> System.Reflection.AssemblyConfigurationAttribute
> System.Runtime.Remoting.RemotingConfiguration

Could you please attach a repro project?
Comment 2 André 2016-11-11 13:53:31 UTC
I have the same error, see attach screen shot.

I think we are confuse by Visual Studio...

We are able to reference System.Configuration.dll in a droid project, with no error/warning until we run our project.
Comment 3 André 2016-11-11 13:54:39 UTC
Created attachment 18427 [details]
Screen shoot error
Comment 4 Jon Douglas [MSFT] 2017-10-04 16:01:32 UTC
Because we have not received a reply to our request for more information we are closing this issue. If you are still encountering this issue, please reopen the ticket with the requested information. Thanks!

For a full list of assemblies that are supported in Xamarin.Android you can find documentation here:

https://developer.xamarin.com/guides/cross-platform/advanced/available-assemblies/#Supported_Assemblies

Thus https://bugzilla.xamarin.com/show_bug.cgi?id=41240#c1 is saying that you cannot add this assembly to your project as it's not supported.

Note You need to log in before you can comment on or make changes to this bug.