Click here to Skip to main content
15,913,854 members
Home / Discussions / C#
   

C#

 
GeneralRe: Excel and C# Pin
abhiram_nayan9-Mar-09 21:39
abhiram_nayan9-Mar-09 21:39 
Question"could not find installable ISAM" error when reading Excel.xls file by OleDbConnection Pin
imio249-Mar-09 14:47
imio249-Mar-09 14:47 
AnswerRe: "could not find installable ISAM" error when reading Excel.xls file by OleDbConnection Pin
Mycroft Holmes9-Mar-09 21:24
professionalMycroft Holmes9-Mar-09 21:24 
QuestionTelent connect for Oracle.Net app Pin
BrianWood9-Mar-09 13:38
BrianWood9-Mar-09 13:38 
QuestionExceptions and out parameters Pin
mringholm9-Mar-09 13:00
mringholm9-Mar-09 13:00 
AnswerRe: Exceptions and out parameters Pin
Christian Graus9-Mar-09 14:07
protectorChristian Graus9-Mar-09 14:07 
GeneralRe: Exceptions and out parameters Pin
mringholm10-Mar-09 5:26
mringholm10-Mar-09 5:26 
AnswerRe: Exceptions and out parameters Pin
Luc Pattyn9-Mar-09 14:55
sitebuilderLuc Pattyn9-Mar-09 14:55 
Hi,

interesting question. I looked into the C# language specification, and it did not provide an answer. It says:

The following definite assignment rules apply to output parameters. Note the different
rules for reference parameters described in §5.1.5.
• A variable need not be definitely assigned before it can be passed as an output parameter
in a function member or delegate invocation.
• Following the normal completion of a function member or delegate invocation,
each variable that was passed as an output parameter is considered assigned in that execution path.
• Within a function member or anonymous function, an output parameter is considered
initially unassigned.
• Every output parameter of a function member or anonymous function must be definitely
assigned (§5.3) before the function member or anonymous function returns normally.


(My underlining) It does not say what happens by abnormal completion. Here is my best guess:
you are passing a BSTR* which reminds me of how I pass writeable strings to native code, by first creating a StringBuilder with sufficient capacity, then calling the native function, and upon return convert the StringBuilder to a string using its ToString() method. This basically tells me the memory passed to the native function is different from the final result, and that conversion probably does not happen when an exception occurs. Hence my suggestion:

- explicitly create a StringBuilder, with sufficient capacity;
- call the native function
- upon its return, whether normal or abnormal, convert the SB to a string.

Doing so I expect you will get the data you are after.

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets


GeneralRe: Exceptions and out parameters Pin
mringholm10-Mar-09 5:23
mringholm10-Mar-09 5:23 
AnswerRe: Exceptions and out parameters Pin
Luc Pattyn10-Mar-09 6:00
sitebuilderLuc Pattyn10-Mar-09 6:00 
QuestionIXMLHTTPRequest Pin
tsahiB9-Mar-09 12:25
tsahiB9-Mar-09 12:25 
QuestionSerialport speed unstable C# Visual Studio 2008 Pin
jondaeh9-Mar-09 10:18
jondaeh9-Mar-09 10:18 
AnswerRe: Serialport speed unstable C# Visual Studio 2008 Pin
Dan Neely9-Mar-09 11:01
Dan Neely9-Mar-09 11:01 
AnswerRe: Serialport speed unstable C# Visual Studio 2008 Pin
Luc Pattyn9-Mar-09 11:16
sitebuilderLuc Pattyn9-Mar-09 11:16 
AnswerRe: Serialport speed unstable C# Visual Studio 2008 Pin
0x3c09-Mar-09 11:17
0x3c09-Mar-09 11:17 
AnswerRe: Serialport speed unstable C# Visual Studio 2008 Pin
Jonathan Davies10-Mar-09 1:56
Jonathan Davies10-Mar-09 1:56 
Questionhow to know who executed my application ? Pin
shabya9-Mar-09 10:11
shabya9-Mar-09 10:11 
AnswerRe: how to know who executed my application ? Pin
Jimmanuel9-Mar-09 10:36
Jimmanuel9-Mar-09 10:36 
AnswerRe: how to know who executed my application ? Pin
harold aptroot9-Mar-09 10:40
harold aptroot9-Mar-09 10:40 
GeneralRe: how to know who executed my application ? Pin
shabya10-Mar-09 12:20
shabya10-Mar-09 12:20 
AnswerRe: how to know who executed my application ? Pin
Dragonfly_Lee9-Mar-09 19:47
Dragonfly_Lee9-Mar-09 19:47 
GeneralRe: how to know who executed my application ? Pin
shabya10-Mar-09 12:21
shabya10-Mar-09 12:21 
GeneralRe: how to know who executed my application ? Pin
Dragonfly_Lee11-Mar-09 1:17
Dragonfly_Lee11-Mar-09 1:17 
Questionwhy is it not writing to screen the first line/value in the txt file this code? Pin
wwwxyz9-Mar-09 10:07
wwwxyz9-Mar-09 10:07 
AnswerRe: why is it not writing to screen the first line/value in the txt file this code? Pin
Rutvik Dave9-Mar-09 10:19
professionalRutvik Dave9-Mar-09 10:19 

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.