Archive, NHibernate

NHibernate and Text fields

Jason / October 11, 2006

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; } } read more

Archive, ASP.NET

Web Services & Self Signed SSL Certificates

Jason / September 20, 2006

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
}

}
read more

Archive

Rebirth

Well, WWDC is this week, and the new Power Macs… um…. Mac Pros have been announced. The name might not be as cool, but it is still awesome. It truly is sad to see Power die… but I understand the reasoning, and applaud Apple on handling the transition so well. read more

Archive

My Xbox

I received my sticker the other day, thanks Jeff! I have seen several people put their stickers on their laptops, and while it is an awesome idea… I wanted some just a little different.
After some thinking, I decided to put it on my Xbox… so here you go:
Image Hosted by ImageShack.us
Again, thanks for the sticker! read more

.NET, Archive, Visual Studio

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. read more