dllimport


Using C# dll in Windows phone 7


I've tried using C# dll in Windows phone 7 but it occurs error after start debugging as illustrated below.
Troubleshooding tips:
If the access level of a method in a class library has changed, recompile any assemblies that reference that library.
Get generral 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 any problem? if not, using C# dll for WindowsPhone7 is impossible?
The C# Dll loaded well in visualstudio2008 C#.
Why are you trying to use P/Invoke on a class library written in C#? Just add a reference to the DLL and use it 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, but you can use class libraries (built for Windows Phone 7).

Related Links

how to use DllImport in metro-style app
Converting doc file to post script
How can I get a COM component which can be used on Windows phone 8 project with C#
Externs and DLL imports
Mixed native and managed code heap corruption
MarshalDirectiveException
call unmanaged C++ code from C# using pinvoke
Detecting DLL Code Splicing
WOW64 Redirection and LoadLibrary
Using C# dll in Windows phone 7
Python 2.5 Import dll AttributeError
Replacing the Import Table in PE file by standart LoadLibrary
Unresolved external symbol
Declare and <DllImport> in VB.NET have different results
how to import/export dll and use its function
HELP linking library in DLL project

Categories

HOME
kentico
solaris
package
vscode-extensions
static-site
cq5
spring-session
frontend
recordrtc
openpyxl
watson-conversation
windows-ce
naivebayes
code-generation
renjin
symbol
altera
event-sourcing
symfony-2.8
html5-appcache
bourbon
pagespeed
event-store
interpreter
jboss6.x
custom-post-type
ms-access-web-app
datastax-enterprise-graph
calculation
send
zend-debugger
papaparse
gojs
instantiation
openwhisk
browser-extension
hivemq
jvmti
urlsession
stringtokenizer
plaintext
avcapturedevice
ovf
builder
clarifai
gitlist
wcftestclient
identification
android-testing
lsyncd
cmp
universal-analytics
juice-ui
testrail
redistributable
winusb
clipboard.js
mediametadataretriever
lz77
custom-errors
iokit
page.js
sapscript
alloy-ui
nutiteq
fits
bcache
gamekit
document-repository
apache-spark-1.3
packet-sniffers
sonarqube-5.0
insight.database
malformedurlexception
xml-dsig
ray
spring-remoting
authlogic
xmltodict
android-usb
light
gtm-oauth2
http-patch
mysql-error-1044
model-driven-development
flex++
poker
stacky
server-administration
preload
robotlegs
adobe-media-server
fitbounds
expression-blend-4
twitterizer
mtu
resharper-6.0
application-verifier
scrubyt
image-capture

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App