dllimport - Using C# dll in Windows phone 7 -
i've tried using c# dll in windows phone 7 occurs error after start debugging illustrated below.
troubleshooding tips: if access level of method in class library has changed, recompile assemblies reference library. generral exception.
this 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 + j; } } }
is there problem? if not, using c# dll windowsphone7 impossible? c# dll loaded in visualstudio2008 c#.
why trying use p/invoke on class library written in c#? add reference dll , use directly:
using mathlibrary; ... private void button1_click(object sender, routedeventargs e) { messagebox.show("test " + add.addinteger(3, 4)); }
you can't use p/invoke in windows phone 7, can use class libraries (built windows phone 7).
Comments
Post a Comment