Today I just discovered Google’s custom search engine program, and quickly setup a .NET Search Engine. I have restricted the list of sites to those that cater to .NET topics including non other than geekswithblogs, in addition to others.
Year: 2006
NHibernate and Text fields
In my last post about NHibernate I mentioned using NHibernate.Mapping.Attributes to simplify things.
Since my last post I have had the need to store rather large text data in a SQL Server Text field. My initial attempt was to simply create a C# string property that represented the field as such:
[NHMA.Property(Name="SomeData")] public string SomeData { get { return _someData; } set { _someData = value; } }
I was shocked to learn that the above did not work correctly. What I was experiencing was NHibernate was silently truncating my data to 3000 characters (or maybe it was 4000, I can’t remember exactly). The reason for this appears to be that NHibernate assumes the field type to be of varchar not Text.
The solution to this problem is to inform NHibernate of the field’s true type. As it turns out this can be done by specifying it as type ‘StringClob’.
[NHMA.Property(Name="SomeData",Type="StringClob")] public string SomeData { get { return _someData; } set { _someData = value; } }
Web Services & Self Signed SSL Certificates
Sometimes you want your web services to use an SSL communications channel, but for one reason or another you cannot use a SSL certificate from a major CA.
Just this past week we had just such a need at work. A coworker of mine was having difficulties making web service calls over SSL when the certificate’s CA could not be trusted by .NET. I had mentioned to him that I had done something similar in the past, and offered my help.
I eventually came up wit this solution:
using System;
using System.Net; //For the ServicePointManager
using System.Security.Cryptography.X509Certificates; //for the X509 certificate
using System.Net.Security; //for RemoteCertificateValidationCallback delegate & SslPolicyErrors
public partial class _Default : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e){
ServicePointManager.ServerCertificateValidationCallback
= new RemoteCertificateValidationCallback(certExaminer);
}
public bool certExaminer(object sender, X509Certificate c, X509Chain chain, SslPolicyErrors sllPolicyErrors) {
return true; //true means the certificate is okay to use
}
}
Differences Between Struct & Class
This site has more than you ever wanted to know about the differences between Classes and Structs in C#. The only thing I did not notice explicitly listed on that site was that Structs always inherit from System.ValueType.
Right On The Money
I just found this article on Joel on Software. While it explicitly mentions Java, it could have just as easily been about C# (with the small exception that no major universities are teaching C#).
For a real brain bender, he provides these sample problems. I would have to say that question 1a was my favorite.
NHibernate
Today was my first real day playing with NHibernate.
The documentation is a little much for a beginner such as myself, but I managed to struggle through it… especially with the help of my coworkers.
Rebirth
How good is your browser?
Popuptest.com provides a battery of tests to see how good your browser is. See if your browser has what it takes when put up against these tests.
It think it goes without saying, but… This site has popups!
Enjoy.
My Xbox
Accessing XML Comments At Runtime
I have wondered for a long time how to access a Types XML comment data at run-time. I know that comments are normally thrown away in languages, but I figured that .NET must keep the XML comments around somewhere, how else could they display the information through intellisense for user created DLLs.
Well, according to this article that I just found, the XML comments are thrown away like all other comments at compile time.
It seems that intellisense attempts to load a separate .XML file to display the comments.