|
Can you try the following code :
string[] MyString = {"Hello", "and", "welcome", "to", "my" , "world!"};
I am not sure the exception you have is a marshalling issue.
And I swallow a small raisin.
|
|
|
|
|
Thank you, Stephane, but It doesn't work. I always thought this was the correct solution, but it gaves me the System.NullReferenceException exception.
If you have any other idea, please let me know.
Thank you,
Edgar
Edgar Berengena Moreno
Software Engineer
Appeyron Research
|
|
|
|
|
Hi maybe I can help.
1. Create arrays, like normal
2. Before calling function, foreach array, allocate mem, copy array to pointer and pass the pointer.
3. when the array returns copy the pointer back to the array.
For example: From MDSN
int[] array2 = new int[ 10 ];
int size = array2.Length;
IntPtr buffer = Marshal.AllocCoTaskMem( Marshal.SizeOf( size )
* array2.Length );
Marshal.Copy( array2, 0, buffer, array2.Length );
int sum2 = LibWrap.TestRefArrayOfInts( ref buffer, ref size );
if( size > 0 )
{
int[] arrayRes = new int[ size ];
Marshal.Copy( buffer, arrayRes, 0, size );
Marshal.FreeCoTaskMem( buffer );
}
Now just do this to each array. Unfortunately u dont give the whole function as defined in a header file, so I cant gaurentee this will work, but it works in my case when normal marshalling wouldnt work
Hope this helps
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
Thanks for your reply, Leppie.
The only problem is that I'm working with string arrays too, so the Copy method of Marshall can't be applied.
I can't say if it works or doesn't work because I need to manage the string array too so keeps receiving the exception...although it seems to work for the double[] (maybe I hope)!!
Any idea for the string array?
PS: the unmanaged DLL parameters (VC++ 6.0 DLL) are defined as
SAFEARRAY FAR *doubleArray, SAFEARRAY FAR *stringArray
...these are the conflicting ones.
Thank you again,
Edgar
Edgar Berengena Moreno
Software Engineer
Appeyron Research
|
|
|
|
|
Hi try this, glad to see double[] works
Try this:
ArrayList tags = new ArrayList();
do
{
string tag = Marshal.PtrToStringUni(ptag);
if (tag == "") break;
else
{
tags.Add(tag);
ptag = new IntPtr(ptag.ToInt32() + Marshal.SizeOf(tag));
}
}
while(true);
This reversse can be done if u need to "feed" the function with the string[].
Hope this works
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
Hi,
I'm trying your second code but I'm having problems and I don't know if I'm doing it quite well. That's what I'm trying now:
For the double[]:
<br />
IntPtr buffer = Marshal.AllocCoTaskMem( Marshal.SizeOf( cantidad ) * sVN.Length);
Marshal.Copy( sVN, 0, buffer, sVN.Length );<br />
...and for the string[]:
<br />
IntPtr ptag = new IntPtr ();<br />
ptag = Marshal.StringToHGlobalAnsi ("maybe...");<br />
ArrayList tags = new ArrayList();<br />
do <br />
{<br />
string tag = Marshal.PtrToStringAnsi (ptag);
if (tag == "") break; <br />
else <br />
{ <br />
tags.Add(tag); <br />
ptag = new IntPtr(ptag.ToInt32() + <br />
Marshal.SizeOf(Marshal.StringToHGlobalAnsi (tag))); <br />
}<br />
}while(true);
And I define the DLL Function like:
Method (..., ref IntPtr sbufN, ArrayList sbufC, ...);
What am I doing wrong?
Thank you again for your dedication,
Edgar
__________________________________________
Edgar Berengena Moreno
Software Engineer
Appeyron Research
|
|
|
|
|
HoHa what a mess
Method (..., IntPtr sbufN, IntPtr sbufC, ...);
string[] strarr = new string[]{"one","two","three","four"};
IntPtr firstpointer;
int counter = 0;
foreach (string str in strarr)
{
IntPtr ptr = Marshal.StringToHGlobalUni(str);
if (counter++ == 0) firstpointer = ptr;
}
Method(..., IntPtr sbufN, firstpointer,...);
for (int i = 0; i < strarr.Length; i++)
{
strarr[i] = Marshal.PtrToStringUni(firstpointer);
firstpointer = new IntPtr(firstpointer.ToInt32() + Marshal.SizeOf(strarr[i]));
}
Ok try that Like I said it is very important to know whether the function will need values from the string array when passing it to the function. What is the function to do / return with the string[] ???
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
A virtual keyboard is a form with keys (buttons) that act as keyboard on touch-screens (for example)
Thanks
Stephane
|
|
|
|
|
There is the UI part and there is virtual key localisation.
About UI, the simplest is to add KeyPress or KeyUp event handlers to your form, so it hooks every key. Then e.KeyCode, or e.Key depending on the handler will return the virtual key code or ANSI code.
Add an imagelist to buttons. And swap images along in event handlers. That will do highlighting.
About localisation, well that's a job that takes time because you'll have to provide cultures keyboard schemes such like AZERTY in French. Which means you have to provide a different set of positioned buttons.
You may of course limit yourself with QWERTY, but ...
My 0.5 cent,
And I swallow a small raisin.
|
|
|
|
|
Just thought I would make people aware of something I noticed, ok it took me a while to work out why and I had to tell somebody ...
I just noticed that if you use the method BringToFront for a label control the index for the control moves.
- James
|
|
|
|
|
I would like to build an application which incoporates 2D graphics. Macromedia / Shockwave jumps to mind in terms of the graphic content I would like to aim for.
I've considered using DirectX but this seems like overkill, and besides there is presently no C# interface to DirectX and I would need to program in C++ to use the SDK (correct me if this statement is wrong, please!).
I'm not out to build a web enabled program and I don't need cross-platform portability.
Does anyone know if there is a 2D graphic engine / library out there which works with .NET? (prefereably C# but C++ is okay).
Thanks in advance!
Only change is constant
|
|
|
|
|
Have you looked into using the System.Drawing.2D namespace? That is .NET's interface to GDI+. If 2D is all you're going to do, you may just want to use that.
David Stone
But Clinton wasn't a predictable, boring, aging, lying, eloquent, maintainer-of-the-status-quo. He was a predictable, boring-but-trying-to-look-hip, aging-and-fat-but-seemingly-oblivious-to-it, lying-but-in-sadly-blatant-ways, not-eloquent-but-trying-to-make-up-for-it-by-talking-even-more, bringer-in-of-scary-and-potentially-dangerous-new-policies. And there was also Al Gore. It just wasn't *right*.
Shog9
|
|
|
|
|
Alastair Stell wrote:
I've considered using DirectX but this seems like overkill, and besides there is presently no C# interface to DirectX and I would need to program in C++ to use the SDK (correct me if this statement is wrong, please!).
I've seen on websites that people has done games in C# using DirectX.... if they're dreaming or what, I don't know!
But I'm pretty sure it is a DirectX for C#!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Many developers have made fine games using VB, thus using C# should be more or less the same.
Of course there are bottlenecks. For instance a .Net application needs at least 4 seconds before it starts (time required for the CLR to compile IL code into assembly code). So don't expect much about time response.
You have at least two options :
- use plenty of ActiveX, for instance the one from Macromedia
- use the System.Drawing assembly, even though you'll end up as with Java 1.0 back 4 years ago : in other words, 1. anything you do requires you to manage your own double buffers, and optimized drawing so the screen does not flicker. 2. the object model is primitive : for instance you cannot draw an arrow. 3. Transparency API ? play with caution, some features will work only on W2K/XP systems. 4. DirectX ? never assume that what works fine on your computer will work on someoneelse's computer. That's the conclusion I made after 2 years of DirectX struggle (where the so-called hardware abstraction at the basis of the whole stuff, is in fact a complete lie). Besides that, manipulating all interface versions will require a full-time job just for it.
And I swallow a small raisin.
|
|
|
|
|
You mite want to consider DirectDraw as it will provide wit an overlay layer if available allowing the CPU to be freed up alot. But its only really worth it if you are using alot of drawing.
Alternative is what is said above, using the Shockwave Flash ActiveX control in you application. Search the forum for FLASH , i put some code in a post a while back on how to use the ActiceX control.
Hope this helps
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
To all interested, I have updated nBASS to have WMA Streaming support as well WMA encoding to file and network.
Here the link to the source (251kb)[^].
Naturally , you will need bass.dll and basswma.dll from the BASS home page[^].
Here's the changes:
nBASS 0.9.3 (1 September 2002)
- Added WMA streaming support, needs basswma.dll (duh!)
- Added WMAStreamTest with visuals.
- Added FX Parameters property. FX can now be tuned.
- Added GetData(byte[] buffer, int length) to AdvancedChannel.
- Added Stereo FFT flags.
- Added WMA Encoding, woohoo, net radio!
- Added WMAEncoderTest.
nBASS 0.9.2 (29 August 2002)
- Add ProgressInterval property to ChannelBase
- added AdvancedChannel.GetData()
- added StreamTest with visualizers (same as VB.Net) with stereo
- all Debug projects now outputs to a single bin dir in the root. Copy bass.dll & basswma.dll there.
- Increased Progress event to fire even quicker. From 100ms to 20ms.
The source is also nice for seeing a variety of marshalling problems I encountered along the way. You can compare with the docs provided with bass.dll.
To all who finds this usefull, enjoy
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
So when can we expect an article detailing what you had to do to expose BASS to .NET?
A link to the BASS homepage in your post would be great as well
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
James T. Johnson wrote:
A link to the BASS homepage in your post would be great as well
Done
James T. Johnson wrote:
So when can we expect an article detailing what you had to do to expose BASS to .NET?
I'm just recovering from what i feel was some scary marshalling, i'm not sure if everything is even 100%. I will do some testing to see, but I really want to finish the Record part first. I have a very nice a idea for a Voice over IP app doing 2 way encoding from live sources. I would also like to included more documentation, but you know how it goes
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
Hi
I have tried to insert an image into a RichTextBox component but with no result. I have tried with CreateGraphics and drawn an image into it but when I type over the image, it dissapears.
If I load a rtf file containing an image it works just fine but how can I include an image programmaticaly?
I included a Com object RichTextBox6.0 and it has an array of ole objects with the add method but I don`t know what to give it as parameters.
Add(object index,object key,object source,object objclass);
Can anyone help me?
|
|
|
|
|
You have to do it in Paint event I guess.Maybe you can subclass it and handle Paint yourself.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Yes but if I handle the Paint event then I have to do all the implementation of the text formatting and location and everything else.
|
|
|
|
|
Try this ....
//load the image
System.Drawing.Image myimage = System.Drawing.Image.FromFile("Sample.jpg");
//create a picture box
PictureBox mypb = new PictureBox();
mypb.Image = myimage;
//adjust the size
mypb.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.richTextBox1.Controls.Add(mypb);
|
|
|
|
|
It works but the text I write is written under the picture.
|
|
|
|
|
I write simple web services and add this method to it:
[WebMethod]
public string ReverseString(string message)
{
char[] arr = message.ToCharArray();
Array.Reverse(arr);
message = new string(arr);
return message;
}
When I want to test it in my browser and press Invoke button in new browser his error happend:
System.InvalidOperationException: Unable to generate a temporary class (result=1).
error CS2001: Source file 'E:\WINDOWS\TEMP\p3tapjny.0.cs' could not be found
error CS2008: No inputs specified
at System.Xml.Serialization.Compiler.Compile()
at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings)
at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings)
at System.Web.Services.Protocols.XmlReturn.GetInitializers(LogicalMethodInfo[] methodInfos)
at System.Web.Services.Protocols.XmlReturnWriter.GetInitializers(LogicalMethodInfo[] methodInfos)
at System.Web.Services.Protocols.MimeFormatter.GetInitializers(Type type, LogicalMethodInfo[] methodInfos)
at System.Web.Services.Protocols.HttpServerType..ctor(Type type)
at System.Web.Services.Protocols.HttpServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Hey, Maz
I've just run this and it works fine.
Mazdak wrote:
error CS2001: Source file 'E:\WINDOWS\TEMP\p3tapjny.0.cs' could not be found
What's the name of your class?
Cheers,
Simon
"Sign up for a chance to be among the first to experience the wrath of the gods.", Microsoft's home page (24/06/2002)
|
|
|
|