|
|
I am trying to create an on update event and have recieved the following error:
An object reference is required for the non-static field, method, or property 'RenishawVMCU.CommandParser.OnUpdate(RenishawVMCU.CommandData)'
It is generated form this line: OnUpdate(rxPortData);
public class CommandParser
{
CommandData rxPortData = new CommandData();
public delegate void delUpdate(CommandData commandData);
public event delUpdate update;
protected virtual void OnUpdate(CommandData commandData)
{
if (update != null)
{
this.update(commandData);
}
}
}
public static string ParseCommand(string m_recievedUCCData)
{
byte[] rxData;
rxData = StrToByteArray(m_recievedUCCData);
CommandData rxPortData = ParseCommand(rxData);
rxData.ToString();
return "Parsing done!" ;
}
public class VirtualMCU
{
public VirtualMCU()
{
cmdParser.update += new CommandParser.delUpdate(cmdParser_update);
}
}
Does anyone know what could be wrong as this is the only line that is causing a problem i cant work it out.
|
|
|
|
|
ParseCommand is a static method.
You cannot access non static methods / members from the static one.
Uri
|
|
|
|
|
This is static
public static string ParseCommand(string m_recievedUCCData)
{
OnUpdate(rxPortData);
} This is not so can only be called by an instance of CommandParser
protected virtual void OnUpdate(CommandData commandData)
{
} If there is no particular reason for the ParseCommand method to be static, then make it an instance member. Alternatively, pass a CommandParser instance as a parameter into the ParseCommand method and act on that.
public static string ParseCommand(string m_recievedUCCData, CommandParser commandParser)
{
commandParser.OnUpdate(rxPortData);
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Thanx for the help. I had not yet learnt of this so was useful information.
i soleved the probelm by passing in the perameter as you suggested which stopped the error.
This is the final code, it didnt have a problem with calling Parsecommand(byte[]) as the method is static.
public static string ParseCommand(string m_recievedUCCData, CommandParser commandParser)
{
byte[] rxData;
rxData = StrToByteArray(m_recievedUCCData);
CommandData rxPortData = ParseCommand(rxData);
commandParser.OnUpdate(rxPortData);
return "Parsing done!" ;
}
|
|
|
|
|
Here[^] is a hint for you.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi,
Created a user i.e. UserA in the domain.
Added this user to the administrators group in serverA.
Using C#, I impersonate this user in my application.
Then using UserA, the application creates a vbscript on ServerA.
Problem is that the vbscript does not get run when I use the processstart call
The error is vbscript engine is not found.
Please note that if I log into the application using my credentials then all works fine and the script runs correctly on serverA.
Do you know why I get the below error if logged in as UserA?
I have also run regsvr32 vbscript on serverA but this does not help in the case of UserA
Error is:
Can not find script engine vbscript for script "path of the vbscript".
Thanks
|
|
|
|
|
hi i can convert an image(in picturebox) in bytes nw i want to compress it hw can i compress it
|
|
|
|
|
Read it into a MemoryStream. Then compress it using the System.IO.Compression.GZipStream class. You could also use the #ZipLib library - there is an article on this site about it (MemoryStream Compression[^])
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
The Subject says it all... At the moment I am using the following method:
Bitmap bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);
Graphics gfxScreenshot = Graphics.FromImage(bmpScreenshot);
gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
However, since I need to be taking screenshots at around every 250ms, I need to find the most efficient way possible (if any)...
Thanks!
Note: I have found that taking partial parts of the screen is much more efficient, but at the moment I need all the screen taken...
modified on Monday, July 20, 2009 3:22 AM
|
|
|
|
|
here[^]
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I must say that that was really helpful...
|
|
|
|
|
hi i m shekhar i having an image tht stored in picturebox i want to convert this image in to bytes plz help me
|
|
|
|
|
MemoryStream ms = new MemoryStream();
pictureBox1.Image.Save(ms, ImageFormat.Jpeg);
byte[] data = ms.ToArray();
ms.Close();
Trace.Write(data);
|
|
|
|
|
Hi..
i take one lebal store text in lebel like E:\Epic\ + textbox1.text + .jpg user type in textbox "1" so label.text is = E:\Epic\1.jpg now i want this location pic show in picbox, user type in textbox 2 then show 2.jpg.
Hope u understand my question.
take care
Thanks In Advnc
jawad khatri
|
|
|
|
|
from what i understand, you want to display the image in the picture box. there should be a Load function for the purpose.
you can do something like:
picturebox1.Load("image path here");
HTH
regards
|
|
|
|
|
my image path is in lebal
picturebox1.Load(label1.text);
i can do this????
|
|
|
|
|
mjawadkhatri wrote: my image path is in lebal
picturebox1.Load(label1.text);
i can do this????
yes, of course.
regards
|
|
|
|
|
yes I have Done Thanks Alot
|
|
|
|
|
Hi All,
I would like to have the code in c# that will import all my contacts of hotmail and AOL into my local database by passing respective credentials.
Any quick help would be really appreciated
Thanks,
Cj
|
|
|
|
|
Have you visited the hotmail and aol sites to see what apis are available? That should be your starting point.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
I've visited the hotmail but there is no such information provided there. Moreover there is no developer community inside hotmail
|
|
|
|
|
Check this google result.[^]
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
the google result doesn't serve my purpose
|
|
|
|
|
you can use this component with .Net, c# and VB.. http://www.socialcontactsimporter.net Worked on our web site like a dream and works with all the major providers, Hotmail, Gmail, Yahoo, Outlook, Outlook Express, Firefox and so on..
We tried a number of ways even creating our own but was no good because the email providers (hotmail etc,) kept on changing their web sites making our code break.. Dont waist your time. Life is too short.
They also do hourly testing to make sure it works.
|
|
|
|