|
Actually, not saying that is the issue here, but I recently worked on a bit of code where not unsubbing the handler caused a COM object to stick around and not get GC'ed even though it went out of scope.
If that object is only getting created once, it wouldn't be a visible issue, but if its getting created repeatedly, I'd unsub the handler.
|
|
|
|
|
Ah, I was only considering .NET objects; there aren't many COM objects in my recent past. And of course there is nothing wrong with unsubscribing at all.
SledgeHammer01 wrote: if its getting created repeatedly
for debugging purposes, I tend to make my objects artificially large, and sometimes create a multitude of them. That way leaks aren't likely to go unnoticed!
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I'll go ahead and add that mapping block for completeness' sake. (I'll just edit my original post to include it)
"I need build Skynet. Plz send code"
|
|
|
|
|
Just try unsubbing the handler and see if that fixes it. If not, move on to the next place. I kind of still think you need to unsub it . Also, I haven't seen your Mapper code. That could be holding on to a ref as well.
|
|
|
|
|
It would have overridden the add method and save the delegate in a static list - evil and unlikely, but possible
|
|
|
|
|
OK, the added code does not refer to client at all, so it still gets collected properly in the end.
The new information is that there is unmanaged memory involved. To deal with that, you should call Dispose(), or apply the using statement, on objects you no longer need if their class offers a Dispose() method; that includes all WinForms Controls, Fonts, Pens, Brushes, Graphics, etc (except for the ones handed to you, e.g. PaintEventArgs.Graphics). I can't help you out in detail, I also am not familiar with Telerik controls. However let's say ServiceClient is a Panel, then you need to call its Dispose().
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Ah. Silverlight. Notorious for leaking like buggery I'm afraid.
|
|
|
|
|
Really? and is there some good reason for that, or have they just been careless?
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Careless. There was a little bit of a dust up about it on the WPF Disciples list about it. I don't think they will make me an MVP now
|
|
|
|
|
Pete O'Hanlon wrote: I don't think they will make me an MVP now
Well, maybe they should, but not before you helped them plugging all the leaks.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Sadly they don't seem interested in fixing the leaks. That's what we were arguing about.
|
|
|
|
|
Do you recall the location of the discussion over on WPF Disciples? (can you provide a link?)
"I need build Skynet. Plz send code"
|
|
|
|
|
I believe the comment was in this[^] thread. This was the bitterest thread that we kicked off - the problem is, it may also be in one of the Disciples private threads.
Actually, I've found the very comment in that thread:
"Here is the hard question I will be asking: Why are memory leaks in Silverlight 4 such a low priority for Microsoft? I cringe every time somebody comes on the WCF RIA Services forum waving an ANTS report trying to figure out where their memory is going."
|
|
|
|
|
I am trying to test a web service that is encapsulated in an IP Phone which is only accessible through HTTPS. I tried HTTP, but it redirects to the secure site.
The system is not connected to the internet and I would like to know if there is a way to make my .NET client ignore the fact it cannot verify the certificate and just proceed with the request. I am using VS 2010 and the class System.ServiceModel.ClientBase<t> (the client code generated with the Add Service Reference feature).
Thank you
|
|
|
|
|
You should be able to do this by overriding the client certificate:
System.Net.ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true); Obviously you want to only apply this during your testing phase, so I'd surround this in a conditional if I were you.
|
|
|
|
|
Absolutely. We just want to test how well we can integrate with the phones and deploy custom services.
Thanks for the answer, it is working well.
|
|
|
|
|
Good job.
|
|
|
|
|
Hey Peter, since you seem to master this topic, I am stuck with the authentication part.
The server requires basic authentication, in the form of a HTTP header:
Authorization: basic <username:passord in base64>
Would you be able to help?
|
|
|
|
|
If you're using WCF, you need to set the authorisation as part of the OperationContextScope. It's fairly straightforward:
MyClient myClient = new MyClient();
using (OperationContextScope scope = new OperationContextScope(myClient.InnerChannel))
{
var reqProperty = new HttpRequestMessageProperty();
reqProperty.Headers[HttpRequestHeader.Authorization] = "Basic " +
Convert.ToBase64String(Encoding.ASCII.GetBytes(myClient.ClientCredentials.UserName.UserName + ":" +
myClient.ClientCredentials.UserName.Password));
OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = reqProperty;
}
|
|
|
|
|
Done!
if(CodeProject.UserProvider.GetUser("Pete O'Hanlon") == CodeProject.UserProvider.GetUser("Le GauChiste")){
System.Net.ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true);
}
"Whether you think you can, or you think you can't--either way, you are right."
— Henry Ford
|
|
|
|
|
Hi there,
I am willing to declare a class, where one of its attributes has to be an Array of integers.
1st question:
How should I write the set and get methods, cause the following is not working.
class Testclass
{
........
private int[] _number;
public int number
{
get { return _number[]; }
set { _number[] = value; }
}
........
}
2nd question:
Not knowing how to deal with the above methods ani in order to advance into coding I declared the attribute as public
public int[] number;
Although I declare a new Object in the Form class (it should be a windows App)
Testclass Myclass = new Testclass();
the programme crashes
Myclass.number[i] = i + 2;
saying that System.NullReferenceException was unhandled and asking me to create a new object instance for Myclass.number[i]
A bit confusing for me...
|
|
|
|
|
There are a few things here. First of all, the return type from number would be int[] not int - the two are not comparable. Secondly, you don't return _number[], you return _number. Finally, why use an array at all? Arrays have the nasty habit of becoming complicated to manage - why not look into a generic List? So this becomes:
class TestClass
{
public TestClass()
{
Number = new List<int>();
}
public List<int> Number { get; set; }
}
|
|
|
|
|
Is this a different list than an ArrayList?
http://msdn.microsoft.com/en-us/library/system.collections.arraylist%28v=VS.100%29.aspx
|
|
|
|
|
class Testclass
{
private int[] _number;
public int[] number
{
get { return _number; }
set { _number = value; }
}
}
number will be null unless you initialize it somehow.
|
|
|
|
|
This is all you need:
public class TestClass
{
public int[] Numbers { get; set; }
}
However, I would probably use a List<int> in the following form:
public class NumbersList : List<int>
{
}
...which would allow you then to do this:
public class TestClass
{
public NumbersList Numbers { get; set; }
}
...as well as being much more flexible than a mere array.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|