Exchanging strings was: Windows Phone

Jaroslav Tulach <[email protected]> Wed, 4 Mar 2015 06:14:31 +0100
Newsgroups gmane.comp.java.ikvm.devel
Message-ID <CAM6-voH7YdZFcZHWZv6BVikBBipLEeP1XWjFTh7cT45G3Y5gnQ@mail.gmail.com>
2015-02-18 9:32 GMT+01:00 Jeroen Frijters <[email protected]>:

> Jaroslav Tulach wrote:
> > > I don't know, but Windows Phone is not supported out of the box by
> > > IKVM.
>


> It means that the code I ship depends on features that aren't available on
> the Windows Phone .NET runtime. If you avoid these features it might work
> (as you apparently found), but it is not "supported" (i.e. intended by me
> to work).
>

Thanks Jeroen, I did some more testing. I can call my

    public static int add(int one, int two) {
        return one + two;
    }

method in my class from my Windows 8 phone application and display the
result. However if I try anything more complex:

    public static int add(int one, int two) {
        WeakReference<Integer> oneRef = new WeakReference<>(one);
        WeakReference<Integer> twoRef = new WeakReference<>(two);
        return oneRef.get() + twoRef.get();
    }

or even something like concatenating strings:
    public static String add(String one, String two) {
        return one + two;
    }

I get

System.TypeLoadException was unhandled by user code
  HResult=-2146233054
  Message=Could not load type 'System.Runtime.Serialization.ISerializable'
from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=7cec85d7bea7798e'.
  Source=plus
  TypeName=System.Runtime.Serialization.ISerializable
  StackTrace:
       at test.Plus.add(Int32 one, Int32 two)
       at App1.MainPage.scriptNotifies(Object sender, NotifyEventArgs args)
  InnerException:

Googling around I found that ISerializable is not supported on the Windows
Phone platform:

----

*gsssrao <https://github.com/gsssrao> * commented on Dec 17 2014
<https://github.com/nicolaspanel/libsvm.net/issues/16#issuecomment-67330870>

The Windows phone does not support the whole of .NET framework, the list of
supported APIs are:
http://msdn.microsoft.com/en-us/library/jj207211%28v=vs.105%29.aspx

So, you get the error:
Could not load type 'System.Runtime.Serialization.ISerializable' from
assembly 'mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=7cec85d7bea7798e'

The ISerializable and SerializationInfo are not present in Windows phone
.NET API.
The Namespace for Windows phone is:
http://msdn.microsoft.com/en-us/library/system.runtime.serialization(v=vs.105).aspx
For .NET framework is:
http://msdn.microsoft.com/en-us/library/System.Runtime.Serialization(v=vs.110).aspx

---

Naïve approach to use -noautoserialization as parameter to ikvmc.exe didn't
help. I guess I am stuck.

What would be your advice for my next step? Thanks.

-jt

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/

_______________________________________________
Ikvm-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ikvm-developers