Giter VIP home page Giter VIP logo

Comments (19)

3F avatar 3F commented on May 29, 2024 1

@Shpendicus

The "empty" export table does not related to NativeStruct use at all. This is not related even for .NET 6 limitation (I hope).

As I said here 3F/DllExport#197 (comment)

Make sure you're looking at correct assembly (x64 or x86 folder if you're using both arch)

Or, please open new issue on DllExport project as a bug since empty export directory. I'll investigate it later. Only please follow report steps and provide all minimal information about settings etc. Thanks.

from conari.

3F avatar 3F commented on May 29, 2024 1

About full sign, here 3F/coreclr#6

maybe im just a jerk xD

Too many features, dependencies, limitations, and a bit documentation.
I mean not everything is so bad :) Feel free to ask, change via PR, or suggest something, and we'll find solution together.

from conari.

CodingMadness avatar CodingMadness commented on May 29, 2024

Sry, my bad, the code issue relied on smth else... forget this ticket!

from conari.

3F avatar 3F commented on May 29, 2024

You're right, UnmanagedStructure is marked as obsolete and planned to be removed in future major releases.

Please note, modern NativeStruct provides several ways https://github.com/3F/Conari/wiki/Quick-start#conari-types

For example, you don't need a CLR types declarations at all if this is a fully automatic way, in your example,

NativeStruct.Make.t<CharPtr, int>("a", "b").Struct;

Also do not need a manual marshaling (Marshal.PtrToString...) everything is automated.

This project unfortunately does not provide some good documentations today, but please first try my tests as an example:

Let me know if you still have some problems, I'll try to look into later.

from conari.

3F avatar 3F commented on May 29, 2024

Sry, my bad, the code issue relied on smth else... forget this ticket!

I see :) Just close it yourself if it's ok

from conari.

CodingMadness avatar CodingMadness commented on May 29, 2024

You're right, UnmanagedStructure is marked as obsolete and planned to be removed in future major releases.

Please note, modern NativeStruct provides several ways https://github.com/3F/Conari/wiki/Quick-start#conari-types

For example, you don't need a CLR types declarations at all if this is a fully automatic way, in your example,

NativeStruct.Make.t<CharPtr, int>("a", "b").Struct;

Also do not need a manual marshaling (Marshal.PtrToString...) everything is automated.

This project unfortunately does not provide some good documentations today, but please first try my tests as an example:

Let me know if you still have some problems, I'll try to look into later.

Thanks so far for that example!

My only question now is: by using .NET 6, i am using "record struct" feature, to test this out, but since i have a feeling that it wont work like this, i created a struct-wrapper around that record-struct, like this:

image

And would this code I have written to allocate unmanaged.memory for that wrapper be okay?

have a look:

image

Thanks in advanced!

from conari.

3F avatar 3F commented on May 29, 2024

but since i have a feeling that it wont work like this

Why? Did you try it?

~
NativeStruct<SomeRecordStructDef> ns = new(instance);

record struct (record ie. records) just tells the compiler to override some default operators and implements some extra logic in basic struct type for new features available in modern C# and so on.

So I don't see the problem as long as it's marked as LayoutKind.Sequential.
Or use Conari's chains to construct any fields at runtime.

If you need some wrapping in any case,

Well, you can implement some cloning of the available fields into some new type like

SomeRecordStruct srs = ...
using NativeStruct<Wrapper> ns = new(srs.Clone());

Or note, NativeStruct also provides accessing to IntPtr if you want to wrap it inside somewhere somehow

NativeStruct<Wrapper> ns = ...
IntPtr ptr = ns;

etc.

from conari.

3F avatar 3F commented on May 29, 2024

by the way, actually LayoutKind.Sequential limitation is not really ... FYI, https://twitter.com/github3F/status/1317526371921502210

from conari.

CodingMadness avatar CodingMadness commented on May 29, 2024

sadly tho, my code based on ur suggestion compiles fine BUT then this:

image

?
here code:

image

This is my converter-record:

image

from conari.

CodingMadness avatar CodingMadness commented on May 29, 2024

image

This is entire function to call the "public static int AllocRecord() {return 10 + 35};" function from .NET 6 and sadly, the equivalent call in Delphi, SEES my exported functions, i get a valid pointer from GetProcAdress(...) BUT when i call it, it shows;:

"External Exception: 0434352"

do you have maybe a clue how this possible? Again, both LoadLib and GetProcAdr do work! and return seeminlgy valid pointers, but then that exception raises for some reason. really strange.

from conari.

3F avatar 3F commented on May 29, 2024

the equivalent call in Delphi, SEES my exported functions

As I see, the "empty" problem is fixed now?

"External Exception: 0434352"
do you have maybe a clue how this possible?

Depends on your configuration. Copy everything from DllExport's Data tab in GUI

Did you try Use our IL Assembler + Rebase System Object ?

from conari.

CodingMadness avatar CodingMadness commented on May 29, 2024

the equivalent call in Delphi, SEES my exported functions

As I see, the "empty" problem is fixed now?

"External Exception: 0434352"
do you have maybe a clue how this possible?

Depends on your configuration. Copy everything from DllExport's Data tab in GUI

Did you try Use our IL Assembler + Rebase System Object ?

sry mate but how u mean "Copy everything from DllExport's Data tab in GUI"

Did you try Use our IL Assembler + Rebase System Object ?
And what u mean by this? I used ur config tool with the GUI, and i did exactly as u did , idk, for the Conari version I m not sure what to use else , i only copied the config from ur GUI in the yt video. :/ not sure what to change.

from conari.

3F avatar 3F commented on May 29, 2024

Modern 1.7+

  1. Check the mentioned options on the right
  2. [Data] - You can find it after end of project list as you can see

for the Conari version I m not sure what to use else

For Conari everything is fine :)

from conari.

CodingMadness avatar CodingMadness commented on May 29, 2024

image

I really, did the exact same settings u took there in the image above. but i get the above error :/

maybe im just a jerk xD

from conari.

CodingMadness avatar CodingMadness commented on May 29, 2024

Mate, what im asking now may sound bit much, i admit, but still ; would you mind, adding me on Discord, and use "Share Screen" and watch me how I do the stuff, and then show me maybe, what i am doing wrong and correct me, (am using .net 6; VS 2022)

i would pay u 3€+ per month :) so from 7 to 10€, if u only help me once with this, its so important for me, getting this done in time since i actually am writing for a company a software module, for my university-internship and i wanted to drastically get this work, managing writing code in new .NET 6 and call it from anywhere unmanaged, like Delphi/FPC/C++ etc..

from conari.

CodingMadness avatar CodingMadness commented on May 29, 2024

@3F forget what i wrote (i will increase the payment to 10€ anyways, dw!) i made it work, bro :-D finally, i forgot to check in the Configurator in your image above, the option: "-nan(ind)" and then it worked fine :)

The only thing now, i wonder: when i want to return string, or Datetime, as I can see for now, i get a valid pointer back from my function but when i cast my funcPtr to the proper and correct function definition:
image

I wonder, why he cant execute that, Free pascal-Compiler executes with code "217", and aborts abruptly. What could cause this?

from conari.

3F avatar 3F commented on May 29, 2024

i would pay u 3€+ per month :) so from 7 to 10€, if u only help me once with this, its so important for me,

:) I appreciate any support to me, however, something like this always reminds me of an attempt to buy me or my time in order to solve some tasks or even complete some work. But it costs a lot more.

i made it work, bro :-D finally

I am glad to hear this!

I wonder, why he cant execute that, Free pascal-Compiler executes with code "217", and aborts abruptly. What could cause this?

For today's DllExport 1.7.4 the .NET 6 support is incomplete and more likely(*) will cause some related errors as it was mentioned earlier in DllExport repo.
(* for some cases it may indeed already be ok, for example, like from my yt video where basic pAdd functions etc.)

Try netstadard2.0, if it will work for the same code then this is it. If no, then something with marshaling that can be fixed in your code.

from conari.

CodingMadness avatar CodingMadness commented on May 29, 2024

:) I appreciate any support to me, however, something like this always reminds me of an attempt to buy me or my time in order to solve some tasks or even complete some work. But it costs a lot more.

Sry for that, that was the reason I regret formulating my sentence like this, I thought it actually more as a little motivation for a quick help ^^ (sry for that..)

for the rest, well i think i will write the entire App for now in Delphi, its to complicated like this :D

from conari.

3F avatar 3F commented on May 29, 2024

for the rest, well i think i will write the entire App for now in Delphi, its to complicated like this :D

Why not temporarily decrease TFM to netstandard2.0 until fixes? or btw netfx-based such as net48
I mean changing some parts of the existing source code (just to be compatible for TFM) is a bit faster than fully rewriting it. Isn't it?

For better you can simply use conditional compilation.

from conari.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.