Source language: Translate to:

Using C# DLLs in NeoBook

Questions or information that don't quite fit anywhere else

Moderator: Neosoft Support

Using C# DLLs in NeoBook

Postby ZeeBoer » Wed May 06, 2015 6:42 am

Hello dear community of NeoBook.

I have the desire (well actually I got told to) get our C# DLLs working in NeoBook (or at least make NeoBook call a function in a C# DLL with multiple string parameters and recieve its string result - preferred would of coarse be any generic type).

The problem here is that I'm originally a Java developer thrown into a C# (ASP.Net MVC4) environment and now got the NeoBook license of a former employee who developed consulting applications with NeoBook. As such small consulting applications found positive feedbacks at our customers, the desire of my management is that such NeoBook applications keep getting developed, but it will be of increasing importance, that those are able to interact with our C# developments. That is where the DLL would come into play.

Thanks to H.P.Wickern and his speedy as friendly reply, i understand that NeoBook as also its plugins are written in Delphi. As for such his DLL plugin does not support C# DLLs. He told me that i would need to write a wrapper plugin and compile the C# DLLs in native mode (tbh no clue what are native DLL but i might find a compile option is Visual Studio to do so).

Before i start working myself into the subject and losing a lot of time on this, it seems logical that such solutions exist already, as C# is a increasingly common language and support might have been needed elsewhere already.

The minimum required functionallity would be:
NeoBook calls a function with several string parameters in the DLL and recieves the result string as response.

I imagine something like this:
[result] = NeoBookPlugin.CallCSharpDll(CSharpDll.GetData(firstname, lastname, city))

If anyone here knows about similar projects, developments or ppl that consider this a perfect opportunity to realize anything like that, I would be more than grateful, as I don"t know Delphi and honestly miss the time to get familiar with Delphi, NeoBook in depth and its plugincreation next to my C# development projects xD.

Thank you very much in advance for any kind of input, no matter how small it might be :)

Sincerely,
Bernd.
ZeeBoer
 
Posts: 12
Joined: Mon May 04, 2015 7:56 am

Re: Using C# DLLs in NeoBook

Postby HPW » Wed May 06, 2015 7:11 am

Hello,

To clarify what ideas I told him by mail :

1.Option: Modify the C# side to allow WIN-DLL calls to unmanaged DLL-functions
https://www.nuget.org/packages/UnmanagedExports

2.Option: Modify the delphi side with commercial product Crosstalk and call .NET functions:
http://ww2.atozed.com/Docs/CT/index.html

3.Option: Modify the delphi side with commercial product hydra and call .NET functions:
http://www.hydra4.com/hydra/tour.aspx

All options I talked about the need of a custom delphi-plugin.
All stuff might be non-trivial.

Regards
Hans-Peter
User avatar
HPW
 
Posts: 2520
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Re: Using C# DLLs in NeoBook

Postby Neosoft Support » Wed May 06, 2015 9:51 am

NeoBook Plug-In SDK below includes some C++ examples:

http://www.neosoftware.com/software/nbwpluginsdk.zip

It's probably possible to convert these to C#. What you could do is create a simple C++ (or C#) plug-in that basically just makes calls to your existing DLLs and passes the results on to NeoBook. This plug-in would be fairly simple since all of the functionality would remain in your existing DLLs.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5603
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Re: Using C# DLLs in NeoBook

Postby ZeeBoer » Fri May 08, 2015 12:43 am

Thank you very much and I'll deal with it this weekend :) Just wanted to make sure that i don't invent the wheel twice ;)

Thanks again also to HPW for his awesome support and pointers :) I'll see what i can get done this weekend :)

Kind regards,
Bernd.
ZeeBoer
 
Posts: 12
Joined: Mon May 04, 2015 7:56 am

Re: Using C# DLLs in NeoBook

Postby stu » Tue May 12, 2015 4:48 am

ZeeBoer wrote:Thank you very much and I'll deal with it this weekend :) Just wanted to make sure that i don't invent the wheel twice ;)

Thanks again also to HPW for his awesome support and pointers :) I'll see what i can get done this weekend :)

Kind regards,
Bernd.


If you manage to pull this off I would be major league interested in a commercial version 8) ...
User avatar
stu
 
Posts: 320
Joined: Wed Aug 07, 2013 11:37 am

Re: Using C# DLLs in NeoBook

Postby ZeeBoer » Thu May 21, 2015 7:03 am

Hello dear NeoBook community, here I am again.

Sorry for the long time of absence and lack of progress information, but i work full time and this stuff is expected to be done "on-the-fly" next to all the other things (at lower priority).

First of all I'm glad to see that immediatly another response came up from another person that seems to be in need of similar functionality. NeoBook seems literally useless in the future without any similar features that makes it able to connect with modern standards and I am rather surprised that the community is told to help itself on such fundamental features. (C++=dead, Delphi=i don't know of any serious programmer that ever dealt with this seriously). My company seems to have paid mentionable amounts for NeoBook plus Plugin licenses, so I really can't imagine what the purpose for NeoBook developers is, if not dealing with the development of such fundamental features (if these seem to be so (I will quote the NeoBook support on this one) "simple" to develop the plugin. Interoperability with modern standard is the key to success accross all platforms and markets in the modern time and this shouldn't be expected to be achieved by existing customers, but it should be done to acquire new ones.

My steps i have done so far:
  • Attempting to get VisualStudio to produce unmanaged DLLs by using the NuGet package recommended by HPW. Problem: No clue if it's even working as i have literally no debugging possibilities. The DLLs are managed as unmanaged exactly of the same size, so i have no clue if it even worked and if the produced DLLs are useful. So I realized: even if I ever manage to build the plugin I would dream of... how would I know it works when while testing it's actually the DLLs that do not match the requirements needed (and there seems to be a lot of different compile options to produce unmanaged DLLs so I have no clue which settings are the ones needed to get the construction to work on our platforms and chances are high that I produces useless DLLs) and might try to fix my plugin until eternity while it was working fine already meanwhile and I'm just going on to destroy it again out of cluelessness.
  • I tried to scan the C++ code... it seems rather technical (as expected ofc) and low level based including assembler parts and tons of pointers (thanks god the modern programming languages took such pain away from us so we can actually concentrate on what really matters - functionality, features and usability). So to be honest: I have no clue how to port this code to C#... if your statement is true, that this conversion from C++ to C# is (i quote again) "probably possible", why don't you do it to offer a (desperately needed) interface to modern programming languages (and standards) and acquire new customer pools. What exactly are people paying their license costs for? Plugins that the community produced themselves as without those NeoBook doesn't seem to offer much? I have no clue what business model NeoBook relies on, but I would be interested how the company expects to place itself on the (tough) market in 5 years :D.
    Anyway - sorry for the offtopic... I used a tool to try to help me getting started with the conversion and hoped that parts that i was unable to do myself get converted, or at least parts of it so that it might give me ideas to complete it another way. Of coarse no huge success... but it gave me some plain facts that make me believe that this is a hopeless case (sadly my boss believes otherwise as you told him that this all seems (can't keep myself to quote again) "simple" and "possible"). As this tool (and research on the net) indicated a major issue to convert the plugin template to C++:
    • Most '__declspec' modifiers cannot be converted to C#
    • __stdcall is not available in C#
All in all i fear this is far beyond my possibilities, interest and time budget so i will re-orientate and do a last attempt to use modern standards into NeoBook before ill announce an epic fail due to missing support from the NeoBook developers:

Is it possible to use webservices in NeoBook? (as in send a JSON request to a webservice on "http://my.service.net/webservice" and recieve at least a string or better a JSON object that i can store in a variable for further processing).

Sorry if any of my statements were taken as accusations, but I highly encourage you to keep an eye on the market development and requirements if you want to place your product(s) successfully on the market in the future. Thank you very much for your time,

Bernd.
ZeeBoer
 
Posts: 12
Joined: Mon May 04, 2015 7:56 am

Re: Using C# DLLs in NeoBook

Postby Neosoft Support » Thu May 21, 2015 11:07 am

It sounds like you're frustrated and needed to take it out on someone.

If I understand your most immediate problem correctly, you're frustrated because the plug-in SDK doesn't have a C# example AND/OR NeoBook doesn't have a generic method for executing a function/procedure from any Windows DLL. Is that correct?

Would it be possible for you to supply us with a sample C# DLL that contains a function/procedure similar to the ones you're trying to use? I may be able to offer some suggestions if I can see what you're trying to do. If interested, you can send files to: info<at>neosoftware.com



C++=dead, Delphi=i don't know of any serious programmer that ever dealt with this seriously.


Actually, C++ is still more popular than C#. If you're interested in empirical evidence documenting the popularity of various programming languages this website may be useful for future tirades:

http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5603
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Re: Using C# DLLs in NeoBook

Postby ZeeBoer » Fri May 22, 2015 1:11 am

Thanks for your reply.

[Offtopic]

Yes, I am frustrated... less because NeoBook doesn't seem to offer what my boss needs (tbh I couldn't care less to say "see NeoBook support answer: computer says no" - little Britain quote here - and uninstall NeoBook again) but more that my boss read exactly 3 words from your reply: "probably possible" and "simple" and now expects me to have it done in 5minutes and i seem to appear too retarded if I don't manage to accomplish it in any shorter time. He just said: "If NeoBook support says it's possible, it IS possible - so just do it.".

Ok that's enough for the source of frustration and sorry if it was taken as accusation (I was trying to point your nose to the severe issues of your product regarding it's struggle of existance in the long run). And i highly doubt that source you quoted... C++ keeps programmers busy with pointers, garbage collection, low level overhead of all kind where other languages achieved to manage to offer all this out-of-the-box with (close to) no performance loss so that programmers can concentrate on the parts that actually represent a modern program instead of struggling with technical difficulties (not to mention a whole lot of very elegantly realized programming patterns). During my study I visited 5 universities (three in Germany, one in UK and one in NL) and only once i came across a C++ class (it was called "C++ practicum" so indicating to be practically orientated). In fact this class was to build a voice recognition program by self training neuronal nets in C++. Learning effect on C++: zero - it was purely applied higher math algorithms that actually had nothing to do with the language they were programmed with. Universities are the center of knowledge, development and by that the indicator of future development... who believes that C++ still has a future in general I would call an optimist (as it simply costs too much time to develop in C++ compared to other options - there will always be resource or hardware critical exceptions which demand C++ developments ofc as it usually happened with older developments as well). Those figures you named are just the justification why young startups counting on new techniques are so much more successful and earning tons more money than the old ones still applying "dead" techniques. I could understand if NeoBook would be realized on a Linux platform as C is part of the Unix base programming and thereby an essential part of Linux that will stay present there for god knows how long and therefore offers an undeniable justification of compatibility strategies... but... it is not. Business success in the IT world is governed by two major topics: effectivity and interoprability - you might wanna think about this (can't speak for Delphi, but C++ just ain't effective and is starting to lose contact to modern standards as modern libraries are misssing). It's a bit like for me MS Access is dead for like ten years... I don't care how many people still use it (there are also still people that believe that the money we have on our bank accounts represent anything or actually have a value more than digital bits and bytes)... when there is no reason anymore to use it, it's a dead, outdated technique that will just slow you down and give disadvantages on the market as you carry overhead with you compared to competitors.

Anyway: NeoBook is your product so you decide if it's positioned right on the market and might have your reasons... i just highly doubt that any market analyst would share those (but i have no glass ball so I don't want to claim to have seen the future).

[/Offtopic]

Back to topic now:

  • Minimum requirement that would allow us to continue realizing some minor projects in NeoBook would be to send a request with a string parameter to a web service and read out a string from the response (not the desired functionality, as we would write webservices with reduced functionality just to make NeoBook be able to communicate with our CMS).
  • Preferred functionality to communicate with webservices would be to send requests to a webservice with a JSON object like this:
    Code: Select all
    {
      "array": [
        1,
        2,
        3
      ],
      "boolean": true,
      "null": null,
      "number": 123,
      "object": {
        "a": "b",
        "c": "d",
        "e": "f"
      },
      "string": "Hello World"
    }

    And recieve the changed JSON object from the relpy to process this by NeoBook (I expect NeoBook to be able to handle JSON objects as i know that Delphi can).
  • Optimum functionality that (if possible) would simply unlock completely new client pools and also would make us (your clients as well as yourself) be able to integrate 3rd party solution features developed in C# into NeoBook would be to have a plugin that can call functions of (unmanaged) C# DLLs that would be able to process function calls with at least basic parameters like int/long/double/char/string and maybe (multidimensional) arrays of such. Possibilities would be endless here and C# will last a lot longer than C++ as I would see it as its successor (I myself am more a friend of Java as the documentation is a lot better, but Java does not produce machine code and needs a java virtual machine interpreter to read the code produced by the compiler - this is why I wouldn't expect a Delphi plugin granting interoperability to java programs of any kind to be possible).

For test reasons I simply created a super small C# DLL containing a function taking any kind of string array parameters and simply always returns a constant string "Hello".

Something that would look like this:

C# class library: MyLibrary.cs
Code: Select all
using RGiesicke.DllExport; // Plugin to produce unmanaged C# DLLs

namespace MyLibrary
{
  public class MyLibrary
  {
    [DllExport("testfunction")]
    public static string testfunction(string[] args)
    {
      return "Hello";
    }
  }
}


As described the size of managed or unmanaged DLLs was exactly the same (to the byte exact) so I can't even tell if I actually produced usable unmanaged DLLs (as so far I didn't need to do so). Also the plugin allows to set options for the unmanaged DLLs like "CallingConvention = CallingConvention.Cdecl" which do not tell me anything, so even if it works, i wouldn't know what settings would be needed to make it work with a C# or C++ plugin for NeoBook. So all in all too many variables in a scenario i can't clearly claim the borders of which tells me to just declare it impossible. Too bad that my boss isn't happy with this point of view xD.

We have several webservices and complete APIs regarding our product(s) that would massively benefit NeoBook applications... As we develop in C#, those will continue to grow and grow and NeoBook would represent what it was once created for (at least i think so), to be an easy wrapper around those to represent the functionality in a quick and dirty way to save extra development costs. Without those functionalities of at least webservices NeoBook would actually lose its purpose completely (actually the reason why - as it seems - there wasn't developed in NeoBook for some time here now and the question arised to integrate/access our existing services into NeoBook to be able to revive the option to ship NeoBook applications again).

Kind regards,
Bernd.
ZeeBoer
 
Posts: 12
Joined: Mon May 04, 2015 7:56 am

Re: Using C# DLLs in NeoBook

Postby Neosoft Support » Fri May 22, 2015 10:07 am

I'll take a look at your C# code and see what we can do.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5603
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Re: Using C# DLLs in NeoBook

Postby Tony Kroos » Fri May 22, 2015 9:10 pm

ZeeBoer, there are a number of plugins developed on pure NET platform without workarounds over last year and more are still in development, so do not worry, I must say it's totally possible. You have to dig into using function and variable pointers and delegates correctly in net, bcoz there are some basic differences in "native" and "managed" approaches to it. Remember that NET has it's own memory management system, so dig more into marshalling issues.
Tony Kroos
 
Posts: 402
Joined: Thu Oct 15, 2009 3:43 pm

Re: Using C# DLLs in NeoBook

Postby HPW » Fri May 22, 2015 10:47 pm

... there are a number of plugins developed on pure NET ...



Hello Tony,

I am not aware of such public plugins. Can you provide more Information?
Who did them? Functions? How do they work?

Regards
Hans-Peter
User avatar
HPW
 
Posts: 2520
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Re: Using C# DLLs in NeoBook

Postby Neosoft Support » Sun May 24, 2015 4:32 pm

Bernd,

...my boss read exactly 3 words from your reply: "probably possible" and "simple" and now expects me to have it done in 5 minutes... He just said: "If NeoBook support says it's possible, it IS possible - so just do it."


Your boss was right! It took a little more than five minutes, as this was my first time using C#, but below is a Visual Studio template that demonstrates how to create a NeoBook plug-in using C#:

http://www.neosoftware.com/software/CSharpNeoBookPlugInTemplate.zip

After compiling in Visual Studio, you will need to rename the the .dll file to .nbp before installing into NeoBook (Options > Install Plug-Ins).
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5603
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Re: Using C# DLLs in NeoBook

Postby HPW » Mon May 25, 2015 12:08 am

Hello Dave,

Sounds great.
Which version of VisualStudio is needed?
Is there a callback-function to neobook?

Edit: Found _nbExecAction in class1.cs

Regards
Hans-Peter
User avatar
HPW
 
Posts: 2520
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Re: Using C# DLLs in NeoBook

Postby Neosoft Support » Mon May 25, 2015 10:29 am

Hello Hans-Peter,

I just used the free community version of Visual Studio available here:

https://www.visualstudio.com/en-us/products/free-developer-offers-vs.aspx

The template will probably work with other versions too.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5603
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Re: Using C# DLLs in NeoBook

Postby ZeeBoer » Tue May 26, 2015 12:02 am

Neosoft Support wrote:Bernd,

...my boss read exactly 3 words from your reply: "probably possible" and "simple" and now expects me to have it done in 5 minutes... He just said: "If NeoBook support says it's possible, it IS possible - so just do it."


Your boss was right! It took a little more than five minutes, as this was my first time using C#, but below is a Visual Studio template that demonstrates how to create a NeoBook plug-in using C#:

http://www.neosoftware.com/software/CSharpNeoBookPlugInTemplate.zip

After compiling in Visual Studio, you will need to rename the the .dll file to .nbp before installing into NeoBook (Options > Install Plug-Ins).

Thank you very, VERY much. I know it might appear lazy, but with a full schedule and the missing believe in a (mainstream) future for C++ (plus missing time to "dig into" techniques that do not benefit to my daily work at all and will be forgotten again in a few weeks/months at best), I am very grateful that I have a solid point to start with (everything else felt just so swampy and undebuggable, that it didn't justify the effort of an approach).

Thanks also to Tony for the input... I read about marshalling in the process of adapting the C++ plugin into C# but I have to admit: as native Java programmer with some basic assembler understanding I still got lost which datatypes needed to be marshalled into what and for what platforms/purposes... And tbh I also didn't see any real option to debug the settings I would have chosen for to test their application after). Imho all overhead and a reason to turn our backs to such techniques and move on to techniques that allow us to concentrate on what counts (at least imho)... Stability, features usability. That's also what (at least I think so) NeoBook was basically created for... once ;)

Tons of thanks again and the 5 minutes for you saved me (and most likely many others) weeks of annoying researches that have nothing to do with our daily business, so don't really bring along any benefits for us after "the job is done".

Kind regards,
Bernd.
ZeeBoer
 
Posts: 12
Joined: Mon May 04, 2015 7:56 am

Next

Return to Misc. Questions and Information

Who is online

Users browsing this forum: No registered users and 1 guest