login about faq

[Updated] Added clarifications based on chilkat's answer.

Suggestion: Instead of having 64-bit and 32-bit managed (.NET) Chilkat Mono dlls have one dll that targets 'Any CPU'.

Why: This will allow any .NET project that uses Chilkat Mono managed dll to be built and deployed independently on both 32-bit and 64-bit machines. E.g. it can be built on 32-bit machine and deployed on 64-bit or vise versa. Also, on 64-bit machine same set of managed dlls can be used in 32-bit and 64-bit processes. Basically, the decision which dll to load is moved from compile-time or install time to run time. That's what 'DLL' abbreviation stands for actually :)

Bonus: You won't have to answer the question about "incorrect format exception" EVER AGAIN.

How: Instead of using DllImport attribute to load unmanaged dll use LoadLibrary and GetProcAddress to bind managed methods to unmanaged calls. In a nutshell, this is the code: http://stackoverflow.com/a/1896685

People did that for many managed/ unmanaged projects, for example ZeroMQ: https://github.com/zeromq/clrzmq/issues/15 https://github.com/zeromq/clrzmq/blob/master/src/ZeroMQ/Interop/UnmanagedLibrary.cs

All the cool kids do that :)

Thanks, Ross

asked Jun 11 '14 at 16:39

Gloomy%20One's gravatar image

Gloomy One

edited Jun 12 '14 at 13:14

Thanks Ross,

I'm copying the information below from another post. The Chilkat .NET assembly does not use DllImport -- it is a mixed-mode assembly that contains a native inner core. The Chilkat for Mono .NET assembly however, does use DllImport. See below:

Try using the "Chilkat Mono" .NET assembly instead.

The difference between "Chilkat Mono" and "Chilkat .NET" is that the Mono implementation is a 100% managed .NET assembly that references a native DLL (or shared lib) for it's implementation, whereas the "Chilkat .NET assembly" is a mixed-mode assembly that is composed of a managed outer-layer API with a native inner core.

It is possible to use "Chilkat Mono" with Visual Studio C# and VB.NET applications, in exactly the same way as using the "Chilkat .NET" mixed-mode assembly -- except that at runtime the Chilkat Mono assembly needs to find and load the native DLL. The name of the native DLL to load is contained in the "ChilkatConst.cs" source file in the Chilkat Mono download. See http://www.mono-project.com/Interop_with_Native_Libraries for information about how the runtime finds the DLL specified by DllImport.


answered Jun 12 '14 at 11:09

chilkat's gravatar image

chilkat ♦♦

Thanks, I didn't know about that part. Still my question remains the same:

Can a new feature be added to Chilkat Mono so it loads the correct native dll at runtime (rather than relying on DllImport attribute)?

I described in my original post how it can be implemented. This would allow any application that uses Chilkat Mono to be truly platform-agnostic ('Any CPU', one set of managed binaries works both in 32 and 64-bit processes).

(Jun 12 '14 at 12:59) Gloomy One
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Jun 11 '14 at 16:39

Seen: 7,429 times

Last updated: Feb 08 '15 at 14:37

powered by OSQA