Using C # dll on a Windows 7 Phone

I tried using C # dll on a Windows 7 phone, but an error occurs after starting debugging, as shown below.


Troubleshooting tips: If the method access level in the class library has changed, recompile any assemblies that reference this library. Get generator help for this exception.


This is the code.

----------------- Windows Phone 7 --------------------------- --- -----------------

using System;
...
using System.Runtime.InteropServices;

namespace DllLoadTest
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
        }

        [DllImport("MathLibrary.dll")]
        public static extern int AddInteger(int a, int b);

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("test " + AddInteger(3, 4));
        }
    }
}

------------------------ C # MathLibrary.dll ------------------- - -------------

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

namespace MathLibrary
{
    public class Add
    {
        public static long AddInteger(long i, long j)
        {
            return i + j;
        }
    }
}

Is there a problem? if not, is using C # dll for WindowsPhone7 impossible? C # Dll is well loaded in visualstudio2008 C #.

+3
source share
1 answer

P/Invoke , #? DLL :

using MathLibrary;
...

private void button1_Click(object sender, RoutedEventArgs e)
{
    MessageBox.Show("test " + Add.AddInteger(3, 4));
}

P/Invoke Windows Phone 7, ( Windows Phone 7).

+2

Source: https://habr.com/ru/post/1777853/


All Articles