Bug 6588 - Android 4.1 GetProperties()
Summary: Android 4.1 GetProperties()
Alias: None
Product: Android
Classification: Xamarin
Component: BCL Class Libraries ()
Version: 4.1.x
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2012-08-17 17:17 UTC by Eugene Bosikov
Modified: 2012-08-20 18:14 UTC (History)
3 users (show)

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

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Eugene Bosikov 2012-08-17 17:17:40 UTC
I have a problem for Android 4.1 , Object from web service doesn't return to me any properties, it works well on Android 3.2 but it doesn't work for Android 4.1 I'm doing a code on Mono for Android. If I'm using Object that I created it works fine, but I do not understand why the same doesn't work for my web reference class, it has 100% public properties. I even tried to do getProperties() whiout any filter. Also For Android 4.1 Properties always return CanWrite=false, it's 100% has get and set. The same code work on Android 3.2 whout a problems. Looks like something wrong with Mono on Android 4+
Comment 1 Jonathan Pryor 2012-08-20 13:15:34 UTC
Can you please provide a sample demonstrating the problem?

Is this a Debug or a Release build?

If it's a Release build, are you linking Sdk and User assemblies, or just SDK assemblies?
Comment 2 Eugene Bosikov 2012-08-20 15:27:40 UTC
This is debug version but it's linking to All Assemblies and SDK.
I coudln't deploy (On Android 4.1) Debug version without Linking All+SDK (As release)

Again it's something wrong also whith Android 4.1 , why I cocyuldn't able to use fast debug without linking.

Forgot to Say , this project created for Android 2.2 to cover all versions 2.2+.

May it helps. This code works on Windows 32, Andorid 2.2-3.2 
But it doesn't work on Android 4.1 . !!!ONLY for class that created by web service tool !!! 

public static T CopyProperties(T1, ...)

T -> object to
T1 -> object from (properties values will be copied from this object), 
T1 class it class generated by web services tool (wsdl).

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace SQLite.Utils
    public class ObjectUtils<T, T1> where T : new()
        public static T CopyProperties(T1 oFrom, ref string sError, string sErrorPrefix, bool bDoNotConvert)
            T oTo = new T();
                 PropertyInfo[] propFrom = oFrom.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetProperty);
                PropertyInfo[] propTo = oTo.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetProperty);

                Dictionary<string, object> propDFrom = new Dictionary<string, object>();
                foreach (PropertyInfo prop in propFrom)
                    propDFrom.Add(prop.Name.ToUpper(), prop.GetValue(oFrom, null));

                foreach (PropertyInfo prop in propTo)
                    if (propDFrom.ContainsKey(prop.Name.ToUpper()))
                        if (bDoNotConvert)
                            prop.SetValue(oTo, propDFrom[prop.Name.ToUpper()], null);

                            prop.SetValue(oTo, GetValue(propDFrom[prop.Name.ToUpper()], prop.PropertyType), null);

            catch (Exception ex) { sError = sErrorPrefix + ex.Message; }

            return oTo;
    }    }
Comment 3 Jonathan Pryor 2012-08-20 17:11:09 UTC
> I coudln't deploy (On Android 4.1) Debug version without Linking All+SDK (As release)

Could you try using the 4.2.5 alpha? (If you're using MonoDevelop, you'll also need a 3.0.4.x alpha as well.)

4.2.5 fixes deployment to API16 devices.

> it's linking to All Assemblies and SDK.

I assume you mean that you're building a Release binary with Linking set to User and SDK assemblies.

Don't do that. Linking will remove types and members that are not statically referenced, which can include constructors, properties, methods, etc. If it's used only by Reflection, it will be collected.

Try setting your Linking to SDK Assemblies (only). Does that fix your runtime issue?
Comment 4 Eugene Bosikov 2012-08-20 18:14:28 UTC
Looks like it deaper. Web service doesn't work, I tought this problem in GetValue method, but it looks like web service doesn't return Dim.