Click here to Skip to main content
16,016,204 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionHow to extract part of a string Pin
dragon5217-Jun-06 18:11
dragon5217-Jun-06 18:11 
AnswerRe: How to extract part of a string Pin
progload17-Jun-06 18:40
progload17-Jun-06 18:40 
Questioncreating databse [modified] Pin
_tasleem17-Jun-06 15:08
_tasleem17-Jun-06 15:08 
AnswerRe: creating databse Pin
Mekong River17-Jun-06 15:53
Mekong River17-Jun-06 15:53 
QuestionUsing USB port Pin
Omar Mallat17-Jun-06 11:53
professionalOmar Mallat17-Jun-06 11:53 
AnswerRe: Using USB port Pin
Mekong River17-Jun-06 16:01
Mekong River17-Jun-06 16:01 
AnswerRe: Using USB port Pin
Dave Kreskowiak17-Jun-06 16:37
mveDave Kreskowiak17-Jun-06 16:37 
QuestionWin APIs different in debug/release (.NET?) Pin
rberman17-Jun-06 10:09
rberman17-Jun-06 10:09 
Hi all. I have a DLL (VB.NET) which uses interop to write to a mailslot -- this is more or less like opening and writing to a file, and is not a problem.

This uses windows API CreateFile, gets a valid handle (no error, valid handle number), and immediately uses it in WriteFile. I have logging that shows the handle number I received from CreateFile is in fact still the same when the error occurs in WriteFile (and other than this logging, there's nothing between them).

Here's the problem:

It works if the DLL is in debug mode when compiled, and fails the WriteFile with "invalid handle" when in release mode. The host application is a simple test app in VB.NET which just creates the object this DLL exposes.


Here is the .NET code

lMailslotHandle = CreateFile(sMailSlot, GENERIC_WRITE, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0)

If lMailslotHandle <> INVALID_HANDLE_VALUE Then
Try
lResult = WriteFile(lMailslotHandle, sMsg2, Len(sMsg2), lNumWritten, 0)

(and there's catch stuff here should any thrown error occur).

The above is enough to cause the problem! Any ideas? That is, lResult is zero and the value of Err.LastDllError is the error code for "handle is invalid".

The data being written is identical whether it is debug or release mode -- there is no code difference at all (in the application code -- obviously there is in the compiled code).

I suspect that I'm getting a wrong error message -- that the handle is not invalid, but that is just a suspicion.

Any ideas?
AnswerRe: Win APIs different in debug/release (.NET?) Pin
Dave Kreskowiak17-Jun-06 16:39
mveDave Kreskowiak17-Jun-06 16:39 
GeneralRe: Win APIs different in debug/release (.NET?) Pin
rberman18-Jun-06 4:57
rberman18-Jun-06 4:57 
GeneralRe: Win APIs different in debug/release (.NET?) Pin
Dave Kreskowiak18-Jun-06 8:02
mveDave Kreskowiak18-Jun-06 8:02 
GeneralRe: Win APIs different in debug/release (.NET?) Pin
rberman18-Jun-06 10:30
rberman18-Jun-06 10:30 
GeneralRe: Win APIs different in debug/release (.NET?) [modified] Pin
Dave Kreskowiak19-Jun-06 1:25
mveDave Kreskowiak19-Jun-06 1:25 
GeneralRe: Win APIs different in debug/release (.NET?) Pin
rberman19-Jun-06 4:29
rberman19-Jun-06 4:29 
GeneralRe: Win APIs different in debug/release (.NET?) Pin
Dave Kreskowiak19-Jun-06 5:08
mveDave Kreskowiak19-Jun-06 5:08 
GeneralRe: Win APIs different in debug/release (.NET?) Pin
rberman19-Jun-06 5:32
rberman19-Jun-06 5:32 
GeneralRe: Win APIs different in debug/release (.NET?) Pin
Dave Kreskowiak19-Jun-06 12:44
mveDave Kreskowiak19-Jun-06 12:44 
GeneralRe: Win APIs different in debug/release (.NET?) Pin
rberman19-Jun-06 6:30
rberman19-Jun-06 6:30 
GeneralRe: Win APIs different in debug/release (.NET?) Pin
Dave Kreskowiak19-Jun-06 12:42
mveDave Kreskowiak19-Jun-06 12:42 
GeneralRe: Win APIs different in debug/release (.NET?) Pin
rberman19-Jun-06 7:00
rberman19-Jun-06 7:00 
GeneralRe: Win APIs different in debug/release (.NET?) Pin
Dave Kreskowiak19-Jun-06 12:47
mveDave Kreskowiak19-Jun-06 12:47 
QuestionSource code for zedgraph bar chart (for 5 Bars needed) [modified] Pin
eric123916-Jun-06 23:24
eric123916-Jun-06 23:24 
QuestionAddressOf CopyProgressRoutine Pin
maple_kisses16-Jun-06 23:13
maple_kisses16-Jun-06 23:13 
AnswerRe: AddressOf CopyProgressRoutine Pin
Dave Kreskowiak17-Jun-06 16:45
mveDave Kreskowiak17-Jun-06 16:45 
Questionplease hepl me Pin
avinashprabhu.t.p16-Jun-06 20:13
avinashprabhu.t.p16-Jun-06 20:13 

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.