Naruto
Naruto

Reputation: 9634

Usage of Desktop C# DLL in windows mobile

i have small query, is there any modification is required in usage of Desktop c# application DLL in windows mobile?. i am getting problem like File or assembly name 'Interop.CDO, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null', or one of its dependencies, was not found.. i have source code of desktop DLL, i don't no what assembly modification i need to do in order to work with mobile.please let me solution..

Thanks in advance Grabit

Upvotes: 1

Views: 1325

Answers (5)

Infinity
Infinity

Reputation: 683

Steps to create the DLL using C++ for Windows Mobile:

1) File > New > Project... > Visual C++ > Smart Device > Win32 Smart Device Project

2) Write a name of the project and click OK.

3) Next > Insert needed SDKs (like WM5 and WM6 ) > Next > Click on DLL > Finish

4) Right click on Source folder and select Add > New

5) Find .def file name it the same as the dll name and click OK.

Now in def You need to write something like this:

LIBRARY    "dllName"

EXPORTS

exactFunctionName1                        DATA
exactFunctionName2                        DATA

In dllName.cpp You need to add those two methods (exactFunctionName1, exactFunctionName2) and write code for them.
You don't need to state more then a method names in def (plus <tab><tab>DATA next to name).

Where to place the DLL after builiding to make use of it in my C# project

It must be placed next to Your app or in Windows folder of Your device.
To get methods from that library just do the following in C#:

using System.Runtime.InteropServices;

[DllImport("dllName.dll")]
private static extern anyReturnType exactFunctionName1(anyArgumentType argumentName);

So as an example let's get arithmethic sum form myMath.dll:

[DllImport("myMath.dll")]
private static extern int sum(int first, int second);

Those methods can be also public but they still require "static extern".

Following example in C++ side You'll have this:

In myMath.cpp:

INT sum(INT first, INT second)
{
    return first + second;
}

In myMath.def:

LIBRARY    "myMath"

EXPORTS

sum           DATA

Source :

http://social.msdn.microsoft.com/Forums/en-US/windowsmobiledev/thread/98e60ab6-aecf-4399-a5be-4937ec40aac9

Upvotes: 0

EKS
EKS

Reputation: 5623

Compile the source code as a mobile dll file.

You can use mobile dll files on the desktop, when it has the compact framework installed. (see comment from ctacke for why)

Upvotes: 2

ctacke
ctacke

Reputation: 67198

You can't use CDO on a mobile device. The "goo" underneath just isn't there so even if you somehow got that recompiled for the device (which I doubt you can do anyway) it still would do you no good. How about telling us what problem you're trying to solve rather than how you've already decided (erroneously) to solve it.

Upvotes: 1

Graviton
Graviton

Reputation: 83296

Can you verify that Interop.CDO is available on your mobile platform? Or that it is compatible with the mobile environment

Upvotes: 0

Ruben Bartelink
Ruben Bartelink

Reputation: 61895

The error message you're getting suggests the DLL isnt present.

If you get past that hurdle, you're still not liley to be home and hosed - CDO is a related to Outlook/Exchange, so isnt very likely to just transparently work.

Upvotes: 0

Related Questions