Need help with writing a DLL

digitaldon37

Active Member
Licensed User
Longtime User
I have been trying to get a DLL that I wrote to work on the Pocket PC in B4PPC. The DLL works on the PC in B4PPC and works in a VB.NET program on the Pocket PC.

As a test, I wrote a simple class that has only one function ("hello") that takes a string for a parameter. The DLL was written in VB.NET using SharpDevelop and compiled to DLL targeting the Compact Framework 2.0

On the PC in the B4PPC IDE, I can add the component ("test44.dll) and add an object "test" to the DLL object " NewClass1". In the B4PPC editor, I can instantiate the object ("test.new1") and execute the function
B4X:
test.new1
msgbox(test.hello("digitaldon") )

When I try this in the B4PPC IDE on the Pocket PC, I get a "An error occurred. NotSupportedException" error.

Any suggestions? (vb.net dll test solution attached)
 
D

Deleted member 103

Guest
Hallo digitaldon37,

I've created your "Test44" with Visual Basic 2008, and it works.


Ciao,
Filippo
 

agraham

Expert
Licensed User
Longtime User
I get the same error on my device. I've looked at the dll with Reflector and it is compiled for .NET 3.5. As I only have .NET 1.0 and 2.0 on my device I guess this is the reason for the error. Does your device have Compact Framework 3.5 installed?
 

digitaldon37

Active Member
Licensed User
Longtime User
I checked and have CF 3.5 on the PDA, but I'm not sure if that is the default. I'm downloading a Powertoys util from Microsoft to see if I can set that.

When I compiled the DLL, I targeted CF 2.0 but if Reflector tells you it's 3.5 that would make sense. I'm using Sharp 3.0 which seems to have some quirks of its own.

Fillipo, thanks for testing. I may have to download a trial of VS2008 to get my DLLs compiled.
 

agraham

Expert
Licensed User
Longtime User
I checked and have CF 3.5 on the PDA
It's probably because the IDE and optimised compiled applications are compiled for .NET 2.0 and the CLR is running them as such but you are loading a .NET 3.5 library. I guess you will need a config file for Basic4ppc.exe to tell the CLR to run it as a CF 3.5 app unless you can persuade SharpDevelop to make a .NET 2.0 assembly.

The CF PowerTools seems to have an "App Configuration Tool (NetCFcfg.exe) - On-device tool for specifying what version of the NETCF runtime an application will run against, displaying installed versions of NETCF and displaying info about DLLs in the GAC." That might be useful.

Download details: Power Toys for .NET Compact Framework 3.5
 

digitaldon37

Active Member
Licensed User
Longtime User
Hallo digitaldon37,

I've created your "Test44" with Visual Basic 2008, and it works.


Ciao,
Filippo

Could you please compile this in VS2008 targeting the compact framework 2.0?
I would really appreciate the favor.

I tried Sharpdevelop on a different PC and got the same error when I tried the DLL on my PDA. I'm going to have to download the trial version of VS2008 and see if that fixes everything - but I would like to get the DLL working for my wiki project.

Thanks, Don
 

digitaldon37

Active Member
Licensed User
Longtime User
It's probably because the IDE and optimised compiled applications are compiled for .NET 2.0 and the CLR is running them as such but you are loading a .NET 3.5 library. I guess you will need a config file for Basic4ppc.exe to tell the CLR to run it as a CF 3.5 app unless you can persuade SharpDevelop to make a .NET 2.0 assembly.

The CF PowerTools seems to have an "App Configuration Tool (NetCFcfg.exe) - On-device tool for specifying what version of the NETCF runtime an application will run against, displaying installed versions of NETCF and displaying info about DLLs in the GAC." That might be useful.

Download details: Power Toys for .NET Compact Framework 3.5

Thanks, I downloaded and tried the netcfcfg but still am having the same problem after trying both 2.0 and 3.5 as the defaults

I also tried a different PC using Sharpdevelop 2 (which shouldn't compile 3.5 framework dll) and still get the same error message.

I'm a little frustrated because I've spent a day getting nowhere today. I appreciate the suggestions - at least I'm learning something from this experience.
 

digitaldon37

Active Member
Licensed User
Longtime User
Thanks, I downloaded and tried the netcfcfg but still am having the same problem after trying both 2.0 and 3.5 as the defaults

I also tried a different PC using Sharpdevelop 2 (which shouldn't compile 3.5 framework dll) and still get the same error message.

I'm a little frustrated because I've spent a day getting nowhere today. I appreciate the suggestions - at least I'm learning something from this experience.

I wrote a simple DLL in C# using Sharpdevelop and CF 3.5 and it works on the pocket pc B4PPC IDE

Unfortunately my C# skills are worse than my VB skills but at least I know that there is hope to resolving this.

Update #1 - I wrote the wrapper in C# (which calls a VB.NET written DLL) and it works on the PC and PDA.
 
Last edited:
Top