Archived Forum Post

Index of archived forum posts

Question:

Chilkat on Rasbian on Raspberry Pi 3

Aug 19 '16 at 06:21

Hi,

I have been doing some testing with chilkat MONO lib on ubuntu x64 machine, and its working beautifully. Now I need to implement same functionality on Raspberry Pi 3 running on Rasbian. The c# code using chilkat/mono/linux that works on ubuntu, does not work on rasbian, but when executing the sample .cs (w/ mono chilkatTest.exe), I get this error:

Unhandled Exception:
System.DllNotFoundException: chilkatMono-9_5_0
  at (wrapper managed-to-native) Chilkat.Crypt2:CkCrypt2U_Create2W (int)
  at Chilkat.Crypt2..ctor () [0x00000] in <filename unknown>:0 
  at ChilkatTest.testCrypt () [0x00000] in <filename unknown>:0 
  at ChilkatTest.Main () [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.DllNotFoundException: chilkatMono-9_5_0
  at (wrapper managed-to-native) Chilkat.Crypt2:CkCrypt2U_Create2W (int)
  at Chilkat.Crypt2..ctor () [0x00000] in <filename unknown>:0 
  at ChilkatTest.testCrypt () [0x00000] in <filename unknown>:0 
  at ChilkatTest.Main () [0x00000] in <filename unknown>:0

I dont know what I should try to do here to get this fixed, is this a problem w/ ARM architecture on Rpi3?

If yes, are there any plans on supporting raspberry? Or is this something totally different?

Many thanks, Matt


Accepted Answer

Now I got it :-) Thank you for this very clear explanation, I'll test it tomorrow w/ my source files. Its really unbelievable to be able to run my app with 100.000+ C# code lines on win/linux/raspberry/osx unmodified. And chilkat has been a great help, as it provides tons of functionality on all these platforms. And refreshingly it does it the way that is very very rare these days: It really works :-)

Thank you again for great libraries and support, Matt


Answer

Here's a new dist that includes a nativeDll/linux/armv7l directory containing a chilkatMono-9_5_0.so This is the ARM shared library that should work on both Raspberry Pi 2 and 3 (and any other ARMv7l Linux).

http://www.chilkatsoft.com/download/preRelease/chilkatMono-9.5.0.zip

If all is well, I'll update the v9.5.0.58 official release with this one because technically nothing changed -- only the ARMv7l .so was added.


Answer

Many thanks for the new armv7 lib! After very minimal testing, everything seems to be going smoothly.

Once again, many many thanks for this extremely quick solution, your support is always 10++ :-)

Cheers, Matt


Answer

Thanks Matt,

It needs a shared lib built specifically for the ARM. I'll try to do this later today.


Answer

The new Rpi library you provided works just great when I compile C# code with mcs on Rpi like this:

mcs -lib:. -r:chilkatMono.dll chilkatTest.cs

But I have not been able to figure out how to link with chilkatMono.dll when I build my c# solution on windows machine w/ visual studio 2015, as on windows I got chilkatDotNet45.dll, and obviously when run on Rpi, when mono loads that ChilkatDotNet45.dll, it will complain what .dll contains native code that cannot be run on this platform.

So essentially I would like to build software on win machine, and then run and test it on Rpi. Do you have any pointers on how to do that?

Or do I just need to build & link with mcs on Rpi, to be able to run it on Rpi.

Many thanks in advance, Matt

ps. I do realize that this was a very poorly explained problem I got, and I do realize that this is not even directly a chilkat issue, but if you got any pointers, that would be greatly appreciated, as I have spent few days on this issue already :-)


Answer

It's actually a very easy solution because w/ Mono, you never link with any native code, even on Windows.

The ChilkatDotNet45.dll is not used w/ Mono. The ChilkatDotNet45.dll is a mixed-mode DLL where the outer-layer is managed and the inner core is native. With the Chilkat Mono solution, the managed and native parts are entirely separate. With Mono, your C# program references a 100% managed Chilkat assembly, which in turn utilizes the native implementation located in either a .so (on Linux), .dylib (on Mac), or .dll on Windows.

See https://www.chilkatsoft.com/mono.asp

The native .so/.dylib/dll files in the Chilkat Mono download are shown here: alt text

The C# source code for the Chilkat layer that utilizes the native implementation is provided in the Chilkat Mono download. You build the managed assembly like this:

mcs -keyfile:chilkat.snk -target:library -out:chilkatMono.dll chilkatCs/*.cs

After doing that, the only remaining step is to copy the native shared lib (.so, .dylib, or .dll) to the directory where your app's EXE is located.

The native shared lib is loaded at runtime via Interop. (See http://www.mono-project.com/docs/advanced/pinvoke/ )

If you open any of the Chilkat .cs source files, you'll see the DllImport's. There's nothing complicated your app needs to do. It's simply a matter of referencing the Chilkat managed assembly, and making sure the native shared lib is located in the same directory as your app's EXE. The native shared lib will be loaded at runtime...


Answer

Hi,

Im trying to add more functionality on my software, and when compiling on Rpi3, I start to get following errors:

./Servers/FTPServer.cs(106,57): error CS0234: The type or namespace name `PercentDoneEventArgs' does not exist in the namespace `Chilkat'. Are you missing an assembly reference?
./Servers/FTPServer.cs(111,56): error CS0234: The type or namespace name `DataRateEventArgs' does not exist in the namespace `Chilkat'. Are you missing an assembly reference?
./Servers/FTPServer.cs(117,58): error CS0234: The type or namespace name `DataRateEventArgs' does not exist in the namespace `Chilkat'. Are you missing an assembly reference?
./Servers/FTPServer.cs(128,38): error CS0246: The type or namespace name `ProgressInfoEventArgs' could not be found. Are you missing an assembly reference?

the c# code for these are as follows:

private void Ftp_OnPercentDone(object sender, PercentDoneEventArgs args)
{
    RealTimeFileStats.PercentDone = args.PercentDone;
}

private void Ftp_OnUploadRate(object sender, DataRateEventArgs args)
{
    RealTimeFileStats.UploadRateBytesPerSec = args.BytesPerSec;
    RealTimeFileStats.BytesTransferred = args.ByteCount;
}

private void Ftp_OnDownloadRate(object sender, DataRateEventArgs args)
{
    RealTimeFileStats.DownloadRateBytesPerSec = args.BytesPerSec;
    RealTimeFileStats.BytesTransferred = args.ByteCount;
}

And when I comment this code out to check if compilation works after that, I get more errors:

./Servers/FTPServer.cs(248,60): error CS1061: Type `Chilkat.Ftp2' does not contain a definition for `GetCreateTime' and no extension method `GetCreateTime' of type `Chilkat.Ftp2' could be found. Are you missing an assembly reference?
./chilkatMono-9.5.0/chilkatCs/Ftp2.cs(8,15): (Location of the symbol related to previous error)
./Servers/FTPServer.cs(341,19): error CS1061: Type `Chilkat.Ftp2' does not contain a definition for `SetRemoteFileDateTime' and no extension method `SetRemoteFileDateTime' of type `Chilkat.Ftp2' could be found. Are you missing an assembly reference?
./chilkatMono-9.5.0/chilkatCs/Ftp2.cs(8,15): (Location of the symbol related to previous error)
./Servers/FTPServer.cs(346,19): error CS1061: Type `Chilkat.Ftp2' does not contain a definition for `SetRemoteFileDateTime' and no extension method `SetRemoteFileDateTime' of type `Chilkat.Ftp2' could be found. Are you missing an assembly reference?
./chilkatMono-9.5.0/chilkatCs/Ftp2.cs(8,15): (Location of the symbol related to previous error)
./Servers/SFTPServer.cs(284,82): error CS1061: Type `Chilkat.CkDateTime' does not contain a definition for `GetAsDateTime' and no extension method `GetAsDateTime' of type `Chilkat.CkDateTime' could be found. Are you missing an assembly reference?
./chilkatMono-9.5.0/chilkatCs/CkDateTime.cs(8,15): (Location of the symbol related to previous error)
./Servers/SFTPServer.cs(409,11): error CS1061: Type `Chilkat.CkDateTime' does not contain a definition for `SetFromDateTime' and no extension method `SetFromDateTime' of type `Chilkat.CkDateTime' could be found. Are you missing an assembly reference?
./chilkatMono-9.5.0/chilkatCs/CkDateTime.cs(8,15): (Location of the symbol related to previous error)
Compilation failed: 5 error(s), 9 warnings

I dont have any glue on why I get these errors, the RPi road has definately been a rocky one...and not talking about chilkat per se, but all in all, weird problems all the time, when something works today, but not tomorrow and vice versa... :-(

Any help would be greatly appreciated.


Answer

Implementing callbacks in Mono C# is different than for Visual Studio C#. See the Events section in the online reference documentation, such as here: https://chilkatsoft.com/refdoc/csFtp2Ref.html

(Scroll down to the bottom for the events..)


Answer

Hi,

Many thanks, the events stuff is now sorted out. Thank You!

I still got errors from compile on Rpi, from code that compiles successfully on windows:

./Servers/FTPServer.cs(305,75): error CS1061: Type `Chilkat.CkDateTime' does not contain a definition for `GetAsDateTime' and no extension method `GetAsDateTime' of type `Chilkat.CkDateTime' could be found. Are you missing an assembly reference?
./chilkatMono-9.5.0/chilkatCs/CkDateTime.cs(8,15): (Location of the symbol related to previous error)
./Servers/FTPServer.cs(399,10): error CS1061: Type `Chilkat.CkDateTime' does not contain a definition for `SetFromDateTime' and no extension method `SetFromDateTime' of type `Chilkat.CkDateTime' could be found. Are you missing an assembly reference?

My code is like this:

if(resource.SetFileDateUseUTC)
{
    // TODO: Verify that UTC conversion works on all platforms Win & linux on x86 & Rpi
    // TODO: Check if utc2.SetFromDateTime(true/false, utc); can do all local/utc conversion for us
    // Convert local time to UTC
    var utc = dt.ToUniversalTime();
    CkDateTime utc2 = new CkDateTime();
    utc2.SetFromDateTime(false, utc);
    success = ftp.SetRemoteFileDt(utc2, filename);
}
else
{
    // Do NOT make any conversions, send local time as-is
    CkDateTime dt2 = new CkDateTime();
    dt2.SetFromDateTime(true, dt);
    success = ftp.SetRemoteFileDt(dt2, filename);
}

So this code works fine on windows, but errors on compile on Rpi. Is the mono lib you sent me over a month ago lagging behind the current windows version? Or is this something else?


Answer

Thank you. Have a nice weekend:-)

-Matt