Click here to Skip to main content
15,903,362 members
Home / Discussions / C#
   

C#

 
GeneralRe: dynamically add a flash object to a C# desktop application Pin
Zap-Man26-Feb-09 5:05
Zap-Man26-Feb-09 5:05 
GeneralRe: dynamically add a flash object to a C# desktop application Pin
EliottA26-Feb-09 5:42
EliottA26-Feb-09 5:42 
GeneralRe: dynamically add a flash object to a C# desktop application Pin
led mike26-Feb-09 7:11
led mike26-Feb-09 7:11 
GeneralRe: dynamically add a flash object to a C# desktop application Pin
led mike26-Feb-09 5:48
led mike26-Feb-09 5:48 
Questioncreate user and role + sql server for existing database programatically Pin
vineesh v26-Feb-09 3:19
vineesh v26-Feb-09 3:19 
AnswerRe: create user and role + sql server for existing database programatically Pin
Jimmanuel26-Feb-09 4:04
Jimmanuel26-Feb-09 4:04 
QuestionDll Import Pin
Alessio Granzotto26-Feb-09 3:13
Alessio Granzotto26-Feb-09 3:13 
AnswerRe: Dll Import Pin
Luc Pattyn26-Feb-09 9:18
sitebuilderLuc Pattyn26-Feb-09 9:18 
Hi,

Some of it looks good, some is less clear. It is always difficult to pinpoint what exactly is wrong; I tend to (1) keep data exchange simple and (2) add logging code on both sides, so I can see which arguments get accross correctly and which don't.

I do have 2 comments:

1.
a native long* can be passed as a managed out long or ref long, it does not need an IntPtr at all. The way your template has it, it is promising the managed world will receive an output pointer, which then natively would require long**
Chances are this is what is causing the error.

2.
I just don't know about szTemplate, I never use [MarshalAs(UnmanagedType.LPStr)] StringBuilder. I prefer a more verbose but easier to understand style as in:
[DllImport("image.dll")]
public static extern long MatchPage(..., StringBuilder szTemplate, ...);

StringBuilder sb=new StringBuilder(1000); // make sure to set initial capacity
MatchPage(..., sb, ...);
string s=sb.ToString();


You must set an initial capacity, that is the size used to allocate the character buffer; and the safe way is to pass that Capacity to the native world so it won't overflow the buffer (similar to strncpy).

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


modified on Sunday, June 12, 2011 8:42 AM

GeneralRe: Dll Import Pin
Alessio Granzotto27-Feb-09 0:42
Alessio Granzotto27-Feb-09 0:42 
AnswerRe: Dll Import Pin
Luc Pattyn27-Feb-09 1:36
sitebuilderLuc Pattyn27-Feb-09 1:36 
QuestionTableLayoutPanel cell removal problem after shuffling it's controls Pin
Muammar©26-Feb-09 2:24
Muammar©26-Feb-09 2:24 
AnswerRe: TableLayoutPanel cell removal problem after shuffling it's controls Pin
Muammar©26-Feb-09 8:46
Muammar©26-Feb-09 8:46 
QuestionForms / Controls flicker during generation. Pin
MatthysDT26-Feb-09 2:23
MatthysDT26-Feb-09 2:23 
AnswerRe: Forms / Controls flicker during generation. Pin
#realJSOP26-Feb-09 3:00
professional#realJSOP26-Feb-09 3:00 
QuestionReccomended books on SQL server 2008 Pin
Mohsen Saad26-Feb-09 1:57
Mohsen Saad26-Feb-09 1:57 
AnswerRe: Reccomended books on SQL server 2008 Pin
Calin Tatar26-Feb-09 2:10
Calin Tatar26-Feb-09 2:10 
Questionprocess extension Pin
shefa' isied26-Feb-09 1:39
shefa' isied26-Feb-09 1:39 
AnswerRe: process extension Pin
EliottA26-Feb-09 2:07
EliottA26-Feb-09 2:07 
GeneralRe: process extension Pin
Calin Tatar26-Feb-09 2:33
Calin Tatar26-Feb-09 2:33 
QuestionHow to split a datatable?? Pin
Member 455443326-Feb-09 1:24
Member 455443326-Feb-09 1:24 
AnswerRe: How to split a datatable?? Pin
moon_stick26-Feb-09 2:54
moon_stick26-Feb-09 2:54 
QuestionTransform Excel to PDF Pin
abbd26-Feb-09 0:30
abbd26-Feb-09 0:30 
AnswerRe: Transform Excel to PDF Pin
Shyam K Pananghat26-Feb-09 0:34
Shyam K Pananghat26-Feb-09 0:34 
QuestionRe: Transform Excel to PDF Pin
abbd26-Feb-09 2:14
abbd26-Feb-09 2:14 
QuestionRe: Transform Excel to PDF Pin
abbd26-Feb-09 2:32
abbd26-Feb-09 2:32 

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.