16,022,752 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Visual Basic questions
View Javascript questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by amirea (Top 8 by date)
amirea
1-Mar-21 8:56am
View
Thank you for sticking around and helping me! It turned out that my code was valid but it took me 1.5 days to figure out that the errors are a bug of the IDE's. After building with the errors still there, the errors were gone.
It didn't occur to me but I found this:
https://stackoverflow.com/questions/3015624/how-to-declare-type-conversion-in-header-file-and-implement-in-cpp-file
and please see the op comment saying it worked with clean project:
https://stackoverflow.com/questions/3015624/how-to-declare-type-conversion-in-header-file-and-implement-in-cpp-file#comment3082516_3015624
and I admit I had my reserves, I tried clean -- didn't work, then built and that solved it. Still, that's a shame... What would happen if the project would need 5 minutes of build time? Imagine building at every error :)
Back to your code: it is clearer than what I wrote and I'll go with that. Thanks again.
amirea
26-Feb-21 3:54am
View
Thanks. There's a problem though, all information and examples on custom conversion function I found on Google, including that at the link you provided don't involve namespaces. And they don't present it split into header and implementation files.
_This_ apparently makes the difference in my case.
amirea
25-Feb-21 13:53pm
View
I know the types, I chose to use integer instead of floating point for precision and consistency reasons. And thank you for pointing that out, there's never too much or too obvious information.
amirea
25-Feb-21 13:49pm
View
Thank you for taking a look at the code. I don't want to just get things done. I want to learn the proper way to do it. Learn once, use it forever :)
amirea
25-Feb-21 13:45pm
View
I must got them confused. I thought they were the same thing.
amirea
25-Feb-21 11:42am
View
I am sorry, as I was saying -- I'm just starting with interop and I probably didn't properly articulate my question.
It was recently that I found out:
1. Primary types are not copied but directly accessed (shared) between runtimes.
2. Arrays are shared as well.
3.
struct
s are passed by value but one can avoid this by passing as <code>ref and pointers.
4.
class
es are copied. But one can avoid this by manually pinning through custom marshaling the type.
5. In all automatic cases (non-custom marshaling) P/Invoke internally takes care of pinning as appropriate from case to case.
6.
IntPtr
is automatically translated back and forth to
void*
.
amirea
23-Feb-21 8:29am
View
Thanks for the comment. I'm not using CLI. just C#/.NET and C++. Also I think I'm missing something on the utility of memory pinning.
My impression is that pinning is necessary in order to refer to the very same variable instance from both runtimes and work with it directly. And that without pinning, a variable would be marshaled (copied or "translated").
Is my knowledge correct? I could be wrong in 2 ways:
1. Maybe you can directly reference an unpinned memory and view it as the variable.
2. Either pinned or not, variable would be marshaled and there wouldn't be any direct interaction with the variable but only through "mediation".
amirea
15-Feb-21 12:03pm
View
Thank you for the insight! I won't be updating all of those very often, just some of them at a given moment.
"each communication is real workload which costs performance"
I'll send all of them in a single call, in an array from C++ to C#.
"Any typed pointer has the advantage of helping you debug - with the cost of some performance"
In this particular case I prefer performance over the debugging options.
There are so many options apparent to me -- somebody that knows next to nothing about the matter but I'm sure there are really just a couple of valid solutions, out of which there's one that fits the bill.
Ideally pinning the object in memory isn't needed (?) and I may get away with
ref
in C# and
&
or
void*
on C++ side.
Show More