|
Hi,
C# calling native code needs P/Invoke, AFAIK there is no way around that.
Ask your friend for details of his method!
|
|
|
|
|
Hi Luc,
I just found i even have VB dlls does that help getting it done the easier way, I mean I don't mind learning new things, but don't have much time, but if their is no other go i will keep learning about accessing un-managed code in c# using pInvoke.
Thanks a lot for your help,
Regards,
Karmendra Suthar
|
|
|
|
|
Hi,
if that is old VB stuff, it is still native code and C# needs P/Invoke.
if that is managed VB.NET code, then it can be called directly, just instantiate the classes and
operate on the properties and methods as if it too were C# code.
|
|
|
|
|
Hi all,
Iam a newbie,
I retrieve the table from Database.
I need to enter values in the GridView Cells directly When i click EDIT in girdview.
protected void GridView2_RowEditing(object sender, EventArgs e)
{
GridView2.SelectedRow.Cells[3].Focus();
}
this is giving me an error.
"Object reference not set to an instance of an object".
After editing i have an "update" in gridview that updates in database, i can do this.
What code i need to put in RowEditing event, so that it takes my values entered in cells.
Thanks in advance.
|
|
|
|
|
I'm trying to read data from a specific binary file format, and have done well until now.
I need to read title and artist info from this file, but it is not in your typical string format where the first byte indicates the string length. It is also not serialized.
It is simply a string of 64 bytes.
As it is, readstring truncates the first character of the string as it's looking for the string length as the first byte which doesn't exist.
I've tried readchar with a for loop but this increases the load time of the file to an extreme.
I've also tried to use readbytes[64], but this always returns "System.Byte[]" instead of the actual info. I've not been able to find any valuable usage info for this method, so I'm certain I'm not using it correctly.
I've tried
read.readbytes[64];
and
read.readbytes[64].tostring();
both return System.Bytes[] as the value.
I've then thought of reading the bytes using readbytes, and then inserting the string length, so as to re read using readstring, but I'm not getting anywhere with this method either.
I'm looking for proper usage of readchars, or readbytes to return a meaningful value.
Any suggestions welcome, but I cannot alter the source. ReadChar works, but as stated, takes much to long to load. Not looking to use unsafe coding if at all possible, as that may be just as extensive loading as the looped readchar method.
|
|
|
|
|
Convert an array of bytes to a string with System.Text.Encoding.ASCII.GetString ( bytes ) (or one of the other encodings).
|
|
|
|
|
Hi Jeff,
when it is just bytes, read the bytes; don't even consider using chars (they aren't chars, a .NET char takes 16-bit) or strings. A .NET string is not represented by a length followed by 8-bit chars, as e.g. Pascal used to do. System.String is a sealed class, and you are not even supposed to know how a string is implemented.
And the ToString() result of a byte array simply gives its type, as you discovered, not its content.
You need to specify how things are encoded, as PIEBALD suggested.
|
|
|
|
|
Thank you both!
I think I've got it.
|
|
|
|
|
Hello everyone,
I've got a little problem.
In an office, there is a server running with a program and in that program is a button to switch off all the lights.
But I would like to have a phisical button. Let's say that we use a keyboard button.
The problem is that there is no source code for the serverprogram. So I would like to know if it is possible to make another program, which can get an keyboard-event and let this event click on the button in another program?
And a happy new year to all of you!
|
|
|
|
|
You can find the window handle of the button and send it a message. It's fiddly, hacky and ugly, but it will work.
The second half, you can write a system wide keyboard hook, or another program which, when it's got the focus, gets the keyboard event, then finds that window and sends it the message.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
hmmmm, I wanted to do this for a long time, is it possible if I just use the Mouse? a program that will set the position of the mouse on the screen using coordinates and then the mouse CLICKS (without user interaction) using a code.
|
|
|
|
|
haha, I like this anwser. Simple and maybe usefull, though it's tricky when the screen changes or is moved. But thanks for this insight.
|
|
|
|
|
Hire a programmer
I are troll
|
|
|
|
|
I am the programmer, still learning, but I just needed some solution-idea's to the problem.
As I have the idea's, I can try to build the app.
|
|
|
|
|
It was a rude statement, my apologies.
The server-application is running under Windows? In that scenario, FindWindow and SendKeys will do the trick, as other people already mentioned.
I are troll
|
|
|
|
|
I forgive your stupidity
Thank you very much. I guess I'll conquer this problem.
|
|
|
|
|
i have a class
public class Command
{
public int Number;
public int Parameters;
}
then 1 xml file :
<common>
<command number="0">
<response parameters="2">
<command number="1">
<response parameters="5">
i wanna assign attribute of the class to value in xml file:
Command[] Response = new Command[200];
XmlDocument Reader = new XmlDocument();
Reader.Load("Sample.xml");
XmlNodeList List = Reader.SelectNodes("/Common/Command");
foreach (XmlNode commandnode in List)
{
int i = int.Parse(commandnode.Attributes["value"].InnerText);
Response[i] = new Command();
HartResponses[i].Number = i;
XmlNodeList Child1List = commandnode.ChildNodes;
foreach (XmlNode Child1 in Child1List)
{
if (Child1.Name == "Response")
Response[i].Parameters = int.Parse(Child1.Attributes ["Parameters"].InnerText);
}}
i got error :"Object reference not set to an instance of an object" at the line
Response[i].Parameters = int.Parse(Child1.Attributes["Parameters"].InnerText);
The code can be executed with i=0,but when i increase to 1, i got this error?
How do i solve it?
Thanks
|
|
|
|
|
hung1984 wrote: Command[] Response = new Command[200];
This creates an array of 200 instances of null. Each must be created before you assign values to it.
Response[i] = new Command();
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
they are already created here:
foreach (XmlNode commandnode in List)
{
int i = int.Parse(commandnode.Attributes["value"].InnerText);
Response[i] = new Command();
HartResponses[i].Number = i;
.............
|
|
|
|
|
Any code that assumes a child node exists, is bad code. I guess this attribute is not always there.
A good way to debug this code is to break it up into as many lines as possible, and see which line blows up. The debugger is also a powerful tool.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
i use it cause my xml file surely have the node named Response. But why the error started with Response[1]?
|
|
|
|
|
I assume because that's the one that doesn't have the attribute. Hard to say, I don't see your XML, and you don't say if you did what I told you to do to work out the exact problem.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
thanks a lot. I think there's some mistake with my xml file
|
|
|
|
|
high i am learning crystal reports and have looked at some articles here to find how to create a crystalviewer, after i add a new item(Crystal Report item) i can not see the designer! i just have "myreport.rpt" and "myreport.cs" in my solution explrr. when i double click on "myreport.rpt" it shows me some hex codes and when i d-click on "myreport.cs" it tells me to drag item from toolbox!
how i can launch the designer and add tables and etc....?
|
|
|
|
|
I'm trying out remote debugging from a WinXP Pro machine to a Win 2003 Server machine (where the source code is deployed).
When I try to compile from Visual Studio 2008, the following error is displayed:
Error 1 'CaseTrak.Activities.StatusUpdater.CTSetCaseReviewStatus(string, int)' must declare a body because it is not marked abstract, extern, or partial z:\Projects\CaseTrak.Activities\CaseTrak.Activities\StatusUpdater.cs 37 21
<code>
public bool CTSetCaseReviewStatus(string sCaseID, int iStatus)
<code>
</code></code>
Resolution (http://msdn.microsoft.com/en-us/library/bb397743.aspx[^])suggests to me that get and set methods have to be set for the variable type, however, it does not seem to fit within the context.
Any ideas?
// cs0840.cs
// Compile with /target:library
using System;
class Test
{
public int myProp { get; } // CS0840
// to create a read-only property
// try the following line instead
public int myProp2 { get; private set; }
}
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using CaseTrak.WebServices;
namespace CaseTrak.Activities
{
public partial class StatusUpdater: SequenceActivity
{
public StatusUpdater()
{
InitializeComponent();
}
protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
{
try
{
}
catch (Exception ex)
{
}
return ActivityExecutionStatus.Closed;
}
public bool CTSetCaseReviewStatus(string sCaseID, int iStatus);
}
}
Jon
|
|
|
|