Click here to Skip to main content
15,911,646 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: 64-bit Interop Pin
Leslie Sanford17-Aug-07 7:38
Leslie Sanford17-Aug-07 7:38 
GeneralRe: 64-bit Interop Pin
Luc Pattyn17-Aug-07 7:38
sitebuilderLuc Pattyn17-Aug-07 7:38 
GeneralRe: 64-bit Interop Pin
Leslie Sanford17-Aug-07 7:42
Leslie Sanford17-Aug-07 7:42 
GeneralRe: 64-bit Interop Pin
Luc Pattyn17-Aug-07 7:47
sitebuilderLuc Pattyn17-Aug-07 7:47 
GeneralRe: 64-bit Interop Pin
Leslie Sanford17-Aug-07 8:04
Leslie Sanford17-Aug-07 8:04 
GeneralRe: 64-bit Interop Pin
Luc Pattyn17-Aug-07 8:14
sitebuilderLuc Pattyn17-Aug-07 8:14 
GeneralRe: 64-bit Interop Pin
Leslie Sanford17-Aug-07 11:30
Leslie Sanford17-Aug-07 11:30 
GeneralRe: 64-bit Interop Pin
Luc Pattyn17-Aug-07 12:39
sitebuilderLuc Pattyn17-Aug-07 12:39 
First of all, you're welcome.

Second, that is a common situation when the playing field changes.
Things are working fine, they look good, compile without hassles, run great,
so you think they might be correct; and then something changes, it may still
work fine, but we got new information or new insights, and we feel we have
to adapt the code, so we learn new ways to be even "more correct" about it.

I have lots of experience in writing C code for different embedded systems,
and I can tell you, if you use five different compilers, it is just impossible
to write one page of code that all compilers will digest without giving a single
warning.

Things have improved, newer languages are more strict; having a single tool vendor
(Microsoft) also helps. But then documentation, whatever they try, is not good
enough. It is great at describing API functions, and less so for general
principles, do's and don'ts, etc.

And to make matters worse, you need more than is officially available (examples,
suggestions, bug work-arounds, ...) but lots of things you find on Internet
(including on CP) seem OK but are plain wrong, often the authors are satisfied
they got something that works, but did not bother (enough) about correctness and
general fitness.

I did investigate the IntPtr stuff when I developed TrayIconBuster (see one of my
CP articles); I was hoping it would run on XP, Vista and Win64 and had read some
messages signaling pitfalls in Win64. Having only XP-32 available, I had to research
a lot before I came up with "my theory", the one I presented earlier. And I must
admit, I did not get most of it from Microsoft documentation, and I don't really
have proof, having only XP to test on.

In earlier code I did not even use IntPtr, I used uint instead (the IntPtr stuff
did not seem to have any added value, just some coding overhead), but I too learned
it the hard way, so a couple weeks ago I revisited all my P/Invoke stuff and fixed
the pointers. Having my own classes (LP_user32, LP_kernel32, ...) holding the
prototypes helped a lot in finding them all; so it was a matter of adapting the
prototypes, then let the compiler discover the remaining problem spots.

One thing I did not understand from day one I started with .NET is why the heck
doesn't Microsoft do what www.pinvoke.net is trying to do, i.e. provide complete and
accurate prototypes for ALL Win32 functionality; they did provide all the header
files in older Visual C versions, and they must have the files internally.
Having them from MS would have improved their quality and completeness.

Unfortunately I have two more comments:
- there is a concept of safe handles since .NET 2.0; I have not studied it yet;
- I just discovered a "HandleRef" structure, which has existed since 1.0
(although its ToIntPtr method is new since 2.0)

Taken together, I would doubt turning handles simply into IntPtrs is really OK.
So I am afraid the theory is still evolving...

Is this a humbling experience ? I don't know; I do realize the more you learn,
the more you realize you don't know much. But that's fine by me, it won't stop
my eagerness to learn.

BTW I am a chess player, and it is my daily experience: some people know more
about the game, some less. You can try to work your way up, you may succeed in
improving your average, but the net result is some people know more, some less.
However hard you try. Well, unless you are at Kasparov's level that is. Laugh | :laugh:

Cheers.

Luc Pattyn [Forum Guidelines] [My Articles]


this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google


QuestionIs any Record Set Concept is there in OLEDB Pin
Praveen 12317-Aug-07 1:29
Praveen 12317-Aug-07 1:29 
AnswerRe: Is any Record Set Concept is there in OLEDB Pin
Scott Dorman17-Aug-07 10:26
professionalScott Dorman17-Aug-07 10:26 
Questionflash button Pin
michael_jhons16-Aug-07 21:42
michael_jhons16-Aug-07 21:42 
AnswerRe: flash button Pin
pmarfleet16-Aug-07 23:33
pmarfleet16-Aug-07 23:33 
QuestionSource C# for Chinese Chess Pin
Quoc Trang16-Aug-07 17:54
Quoc Trang16-Aug-07 17:54 
QuestionHow To install msi file along with my app setup Pin
Mayur16-Aug-07 4:52
professionalMayur16-Aug-07 4:52 
QuestionHow to raise events while clicking a datalist item or a particular Row?? Pin
bijeshputhalath15-Aug-07 21:42
bijeshputhalath15-Aug-07 21:42 
AnswerRe: How to raise events while clicking a datalist item or a particular Row?? Pin
- Pascal -17-Aug-07 9:11
- Pascal -17-Aug-07 9:11 
QuestionWhy Value types.. Pin
Sendilkumar.M15-Aug-07 21:15
Sendilkumar.M15-Aug-07 21:15 
AnswerRe: Why Value types.. Pin
Urs Enzler15-Aug-07 23:02
Urs Enzler15-Aug-07 23:02 
QuestionOpening a DB Pin
zchwllms14-Aug-07 12:20
zchwllms14-Aug-07 12:20 
AnswerRe: Opening a DB Pin
Dave Kreskowiak14-Aug-07 12:25
mveDave Kreskowiak14-Aug-07 12:25 
QuestionReporting framework for .NET - Open Source Pin
Yuval Naveh14-Aug-07 8:04
Yuval Naveh14-Aug-07 8:04 
AnswerRe: Reporting framework for .NET - Open Source Pin
Pete O'Hanlon15-Aug-07 2:23
mvePete O'Hanlon15-Aug-07 2:23 
GeneralRe: Reporting framework for .NET - Open Source Pin
Yuval Naveh15-Aug-07 3:28
Yuval Naveh15-Aug-07 3:28 
GeneralRe: Reporting framework for .NET - Open Source Pin
Paul Conrad16-Aug-07 15:56
professionalPaul Conrad16-Aug-07 15:56 
QuestionCLR Pin
MarKus014-Aug-07 3:06
MarKus014-Aug-07 3:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.