|
PLSSS DON'T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalisation if you want to be taken seriously.
And while you are at it, drop the txtspk as well...
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
OriginalGriff wrote: PLSSS
Please don't use textspeak.
OriginalGriff wrote: DON'T SHOUT
Isn't that a paradox?
|
|
|
|
|
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
When using VKontakte API method wall.get or friends.get client receives a response just once. When increasing for example the offset parameter such requests do not pass. An error is returned InnerException = {"The request was aborted: Could not create SSL / TLS secure channel."}. What is the possible reason?
|
|
|
|
|
You have posted a fair bit here about this API. I would suggest that you would be better off seeking answers from the support forums at vk.com. You also never seem to show code. Here's a hint, we can't read minds so we don't know what's wrong with your code.
|
|
|
|
|
tfile101 wrote: What is the possible reason?
An invalid certficate?
Bastard Programmer from Hell
|
|
|
|
|
Hi all,
I have some COM components(activex control without wrapper), which are added at runtime. I met with some problem on latebound call to some properties.
for example, a "Picture" property. I can manage to set a stdole.ipicturedisp by this way:
host.GetType().InvokeMember("Picture", BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetProperty, null, host, new object[] { value });
this works witout any problem when value is not null. but when i need to clean the picture by passing value as null, i got a
system.reflection.targetinvocationexception.
everything works if i don't use lateboud, i.e.
host.Picture=null;
any idea on fixing this problem?
thanks in advance..
|
|
|
|
|
Try to pass something like IntPtr.Zero in the place where you are passing null.
Basically, if your com object expects a ref type of variable, it will not be able to accept a null.
You could also create a dummy variable, assign it and then pass it to the com method.
|
|
|
|
|
I tried IntPtr, but it still not work
object value = IntPtr.Zero;
host.GetType().InvokeMember(_Name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetProperty
, null, host, new object[] { value });
System.Reflection.TargetInvocationException
Message=""
Source="mscorlib"
StackTrace:
System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)
Host.Net.AxPictureTest.ClearPicture(Object target)
|
|
|
|
|
How to enable the system managed size of virtual memory using WMI in C#?Kindly help me out how to proceed with it.
|
|
|
|
|
I am using the entity framework to retrieve data from a database. I pull a collection of objects and bind them to textboxes. The problem I am having is when I try to edit the textbox that is bound to an integer field. Any changes I make to the textbox are changed back to the original value when the textbox is exited. Anyone have a solution to this, beside changing all my database columns to varchar?
|
|
|
|
|
You could try to create a custom UserControl that has a TextBox and a bindable property[^] on it to translate the the textbox.Text field into an integer:
[System.ComponentModel.DefaultBindingProperty("NumericText")]
public partial class NumericTextBox : UserControl
{
public NumericTextBox ()
{
InitializeComponent ();
}
public int NumericText
{
get { return Convert.ToInt32(this.textbox1.Text); }
set { this.textbox1.Text = value.ToString(); }
}
}
Jack of all trades ~ Master of none.
|
|
|
|
|
OK, tried that and it still did not work. I do have some details though. It seems that when I exit the textbox, the attribute from the ObjectContext is going to the "get" instead of the "set", so it just returns the original value.
[EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
[DataMemberAttribute()]
public Nullable Discount
{
get
{
return _Discount;
}
set
{
OnDiscountChanging(value);
ReportPropertyChanging("Discount");
_Discount = StructuralObject.SetValidValue(value);
ReportPropertyChanged("Discount");
OnDiscountChanged();
}
}
private Nullable _Discount;
partial void OnDiscountChanging(Nullable value);
partial void OnDiscountChanged();
|
|
|
|
|
I wonder if it would help to cast the value or specify the underlying type of the Nullable object:
private Nullable<Int32> _Discount;
Jack of all trades ~ Master of none.
|
|
|
|
|
Hi,
May I have some fresh eyes please?
Under a Windows service running as LocalSystem, on a 60 second timed interval, I am running the following:
Process Ns = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo("netstat");
startInfo.Arguments = "-ano";
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.CreateNoWindow = true;
Ns.StartInfo = startInfo;
Ns.Start();
Ns.WaitForExit();
for (int i = 0; i < 4; i++)
Ns.StandardOutput.ReadLine();
while (true)
{
string Line = (Ns.StandardOutput.ReadLine());
if (!string.IsNullOrEmpty(Line))
{
Line = Line.Trim();
Line = Line.Replace(" ", " ");
Line = Line.Replace(" ", " ");
Line = Line.Replace(" ", " ");
Line = Line.Replace(" ", " ");
Line = Line.Replace(" ", " ");
Line = Line.Replace(" ", " ");
Line = Line.Replace(" ", " ");
Line = Line.Replace(" ", " ");
Line = Line.Replace(" ", " ");
Line = Line.Replace(":", " ");
Line = Line.Replace('\r', ' ');
Line = Line.Replace('\n', ' ');
string[] s = Line.Split(' ')
if (s.Length == 7)
{
insns.Parameters["@Protocol"].Value = s[0];
insns.Parameters["@LocalHost"].Value = s[1];
insns.Parameters["@LocalPort"].Value = s[2];
insns.Parameters["@RemoteHost"].Value = s[3];
insns.Parameters["@RemotePort"].Value = s[4];
insns.Parameters["@State"].Value = s[5];
insns.Parameters["@PID"].Value = s[6];
}
else
{
insns.Parameters["@Protocol"].Value = s[0];
insns.Parameters["@LocalHost"].Value = s[1];
insns.Parameters["@LocalPort"].Value = s[2];
insns.Parameters["@RemoteHost"].Value = s[3];
insns.Parameters["@RemotePort"].Value = s[4];
insns.Parameters["@State"].Value = "0";
insns.Parameters["@PID"].Value = s[5];
}
if (Line == null)
break;
}
Ns.Close();
Ns.Dispose();
however, for no obvious reason, sometimes after only a few minutes of running or sometimes after many hours I get an exception:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
Can I track which index this is and 'On Error Resume Next' around it? How can I negate this error or dispose of it and continue?
It doesn't matter too much if in one cycle I only get 71 instead of 72 connections dispalayed as, 1 minute later. I collect them all again anyway.
The problem it causes is that the netstat does quit and stays running in the Task Manager which means that all subsequent netstats start piling up behind it and, although the data gets written to the db, I can end up with dozens of netstats in my Task Manager which then have to be End-Tasked.
I am fairly sure that this is because the netstat never gets to .Close & .Dispose thus never receives an Exit signal so the .WaitForExit stays waiting. I am right in this assumption? How can I send it an Exit signal after the exception is called?
Any ideas please?
|
|
|
|
|
CCodeNewbie wrote: I am fairly sure that this is because the netstat never gets to .Close & .Dispose thus never receives an Exit signal so the .WaitForExit stays waiting. I am right in this assumption?
I wouldn't pick it as the first suspect for an "index out of range" message.
CCodeNewbie wrote: Can I track which index this is
Did the exception come with a stack-trace? What is the content of "Exception.ToString()"?
CCodeNewbie wrote: 'On Error Resume Next' around it?
Let's ignore that you mentioned this.
string[] s = Line.Split(' ')
if (s.Length == 7)
{
insns.Parameters["@Protocol"].Value = s[0];
insns.Parameters["@LocalHost"].Value = s[1];
insns.Parameters["@LocalPort"].Value = s[2];
insns.Parameters["@RemoteHost"].Value = s[3];
insns.Parameters["@RemotePort"].Value = s[4];
insns.Parameters["@State"].Value = s[5];
insns.Parameters["@PID"].Value = s[6];
}
elseif (s.Length == 6)
{
insns.Parameters["@Protocol"].Value = s[0];
insns.Parameters["@LocalHost"].Value = s[1];
insns.Parameters["@LocalPort"].Value = s[2];
insns.Parameters["@RemoteHost"].Value = s[3];
insns.Parameters["@RemotePort"].Value = s[4];
insns.Parameters["@State"].Value = "0";
insns.Parameters["@PID"].Value = s[5];
}
else
{
throw new Exception("This is where it probably goes boom");
}
Bastard Programmer from Hell
|
|
|
|
|
Quote: I wouldn't pick it as the first suspect for an "index out of range" message. I meant could that be the reason I get a traffic jam of netstats in the Task Manager
Quote: Did the exception come with a stack-trace? What is the content of "Exception.ToString()"?
I have coded in a .InnerException to try and get the trace. The existing error only gives "System.IndexOutOfRangeException: Index was outside the bounds of the array."
Quote: Let's ignore that you mentioned this. Hee Hee Hee
I have rebuilt and have to wait to see what exceptions may arise. Will advise asap.
|
|
|
|
|
Hi Eddy,
Sorry I haven't got back to you sooner. Did what you suggested but now it makes even less sense:
throw new Exception("failed " + s.Length + " : " + s + " : " + Line);
results in
failed 6 : System.String[] : UDP 0.0.0.0 445 * * 4
pardon my ignorance but why is it ignoring the
if (s.Length == 6) instruction?
|
|
|
|
|
CCodeNewbie wrote:
pardon my ignorance but why is it ignoring the
if (s.Length == 6) instruction?
It shouldn't, if the string can be divided into six different words. The line that has been logged, would be broken down like this;
- UDP
- 0.0.0.0
- 445
- *
- *
- 4
You can verify the result using the code below;
foreach (string someWord in s)
{
System.Diagnostics.Debugger.WriteLine("'{0}'", someWord);
}
Also, can you post your (updated) code again?
Bastard Programmer from Hell
|
|
|
|
|
Hi Eddy,
Usually it does divide. "UDP 0.0.0.0:445 *:* 4" put through
if (s.Length == 6)
{
insns.Parameters["@Protocol"].Value = s[0];
insns.Parameters["@LocalHost"].Value = s[1];
insns.Parameters["@LocalPort"].Value = s[2];
insns.Parameters["@RemoteHost"].Value = s[3];
insns.Parameters["@RemotePort"].Value = s[4];
insns.Parameters["@State"].Value = "0";
insns.Parameters["@PID"].Value = s[5];
} becomes
s[0]=UDP
s[1]=0.0.0.0
s[2]=445
s[3]=*
s[4]=*
s[5]=0
s[6]=4
if I remove the line "insns.Parameters["@State"].Value = "0";"
the output reports "Listening" even though there is no value in the netstat cmd-line output.
Sorry this is taking a while, worked out I had to use System.Diagnostics.Debug.WriteLine instead of System.Diagnostics.Debugger.WriteLine
So, I did
Process Ns = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo("netstat");
startInfo.Arguments = "-ano";
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.CreateNoWindow = true;
Ns.StartInfo = startInfo;
Ns.Start();
Ns.WaitForExit();
for (int i = 0; i < 4; i++)
Ns.StandardOutput.ReadLine();
while (true)
{
Line = (Ns.StandardOutput.ReadLine());
if (!string.IsNullOrEmpty(Line))
{
Line = Line.Trim();
Line = Line.Replace(" ", " ");
Line = Line.Replace(" ", " ");
Line = Line.Replace(" ", " ");
Line = Line.Replace(" ", " ");
Line = Line.Replace(" ", " ");
Line = Line.Replace(" ", " ");
Line = Line.Replace(" ", " ");
Line = Line.Replace(" ", " ");
Line = Line.Replace(" ", " ");
Line = Line.Replace(":", " ");
Line = Line.Replace('\r', ' ');
Line = Line.Replace('\n', ' ');
s = Line.Split(' ');
if (s[0] == "TCP")
{
if (s[1] != "0.0.0.0")
{
insns.Parameters["@Tstamp"].Value = DateTime.Now;
insns.Parameters["@SysID"].Value = SID;
insns.Parameters["@Protocol"].Value = s[0];
insns.Parameters["@LocalHost"].Value = s[1];
insns.Parameters["@LocalPort"].Value = s[2];
insns.Parameters["@RemoteHost"].Value = s[3];
insns.Parameters["@RemotePort"].Value = s[4];
insns.Parameters["@State"].Value = s[5];
insns.Parameters["@PID"].Value = s[6];
NSInfo.Open();
insns.ExecuteNonQuery();
NSInfo.Close();
}
}
if (s[0] == "UDP")
{
if (s.Length == 6)
{
insns.Parameters["@Tstamp"].Value = DateTime.Now;
insns.Parameters["@SysID"].Value = SID;
insns.Parameters["@Protocol"].Value = s[0];
insns.Parameters["@LocalHost"].Value = s[1];
insns.Parameters["@LocalPort"].Value = s[2];
insns.Parameters["@RemoteHost"].Value = s[3];
insns.Parameters["@RemotePort"].Value = s[4];
insns.Parameters["@State"].Value = "0";
insns.Parameters["@PID"].Value = s[5];
NSInfo.Open();
insns.ExecuteNonQuery();
NSInfo.Close();
}
if (s.Length == 7)
{
insns.Parameters["@Tstamp"].Value = DateTime.Now;
insns.Parameters["@SysID"].Value = SID;
insns.Parameters["@Protocol"].Value = s[0];
insns.Parameters["@LocalHost"].Value = s[1];
insns.Parameters["@LocalPort"].Value = s[2];
insns.Parameters["@RemoteHost"].Value = s[3];
insns.Parameters["@RemotePort"].Value = s[4];
insns.Parameters["@State"].Value = s[5];
insns.Parameters["@PID"].Value = s[6];
NSInfo.Open();
insns.ExecuteNonQuery();
NSInfo.Close();
}
else
{
foreach (string someWord in s)
{
System.Diagnostics.Debug.WriteLine("'{0}'", someWord);
}
}
}
when the timer triggered my CPU ramped up to 99% usage by my app and I had to End-Task it. Nothing was written to the Output or the Event log.
|
|
|
|
|
CCodeNewbie wrote: becomes
s[0]=UDP
s[1]=0.0.0.0
s[2]=445
s[3]=*
s[4]=*
s[5]=0
s[6]=4
That's strange; if s[] contains six elements, how did we get seven items here? s[5] should be 4 IMHO, and s[6] shouldn't be there.
CCodeNewbie wrote: worked out I had to use System.Diagnostics.Debug.WriteLine instead of System.Diagnostics.Debugger.WriteLine
Aw, my apologies; I tend to mix them up outside of the IDE. It should list all the words in the array in the output-window of Visual Studio.
CCodeNewbie wrote: when the timer triggered my CPU ramped up to 99% usage by my app and I had to End-Task it. Nothing was written to the Output or the Event log.
Could it be that it's reading a lot of empty lines?
while (true)
{
Line = (Ns.StandardOutput.ReadLine());
if (!string.IsNullOrEmpty(Line))
Bastard Programmer from Hell
|
|
|
|
|
from a cmd-line netstat -ano you can see that the field usually used by "State" tends to be empty under the UDP protocol unless there is some stream coming in in which case it will show "Established" or whatever. Because I am writing the values to a SQL table I need to keep s[6] in the PID column.
Quote: Could it be that it's reading a lot of empty lines? don't think so, usually it works fine until it hits a null/empty value somewhere in the s[] array. What would be ideal is a way of saying:
if (s[whatever].isNullorEmpty){s[whatever] = "0";}
|
|
|
|
|
Select the menu "Debug" and then "Toggle Breakpoint", and use F10 to step through your code.
CCodeNewbie wrote: What would be ideal is a way of saying:
Something like this?
string FetchFromArray(string[] source, int idx)
{
if (idx <= source.Length)
return source[idx];
else
return String.Empty;
}
public Form1()
{
InitializeComponent();
string[] s = "Hello world from Mars!".Split(' ');
Text = FetchFromArray(s, 7);
}
Bastard Programmer from Hell
|
|
|
|
|
Trying to work out why mu CPU is going mad at the moment, I'll get back to this in a bit..
|
|
|
|
|