Categories
Geeky/Programming

.NET 3.0 WPF/WCF Templates for VS2005

Microsoft recently released the .NET Framework 3.0 (WinFX) that includes Windows Presenation Foundation, Windows Communication Foundation, Windows Workflow Foundation, and Windows CardSpace. If you are trying to develop using the WPF or WCF using VS2005, you might be wondering if there are VS2005 Templates avail for these project types. You would think that by installing the Vista SDK and the .NET Framework 3.0 you would have them, but no. After doing some digging, there are extensions for WWF for Visual Studio. For WPF and WCF, you are left with the November 2006 CTP Release of the Extensions, which is the “Cider” Release. I guess from what I am reading, there won’t be RTM versions of these extensions, well, not until the Visual Studio release of “Orcas”.

Now, I guess I don’t mind that the CTP versions are what you are supposed to use, but the problem is there is no where I can find (in one place) where all of this is laid out and specified. You have to dig around on forums and what not. Microsoft should lay out what is what so you don’t have to second guess.

After installing the RTM 2006 Extensions, you should see the .NET Framework 3.0 projects types in VS2005 as shown here:

dotnet3_projecttemplates.JPG

Categories
Geeky/Programming

warning CS0618: 'System.Web.Mail.SmtpMail' is obsolete:

Previously in .net 1.0 and 1.1, to send mail from a console application, you could use

using System.Web.Mail

and use a method similar to this:

static void SendMail()
{
MailMessage msg = new MailMessage();

msg.To = “toaddress1@whatever.com,toaddress2@blah.com”;
msg.From = “fromaddress@whatever.com”;
msg.Subject = “My Subject”;
msg.Body = “My Body”;

msg.BodyFormat = MailFormat.Html;

SmtpMail.SmtpServer = “yourmailserveraddressorip”;

SmtpMail.Send(msg);

}

If you then upgrade to .net 2.0, you will get this when building:

warning CS0618: ‘System.Web.Mail.SmtpMail’ is obsolete: ‘The recommended alternative is System.Net.Mail.SmtpClient. http://go.microsoft.com/fwlink/?linkid=14202’

Nice huh, link doesn’t tell you much except the API is obsolete.
The old way still works, but you get a bunch of ugly warnings.
So, to fix that, you need to do this. First remove the using statement for System.Web.Mail, then add and change your mailing method as follows:

using System.Net.Mail;

static void SendMail()
{
MailMessage msg = new MailMessage();

msg.To.Add(“toaddress1@whatever.com,toaddress2@blah.com”);
msg.From = new MailAddress(“fromaddress@whatever.com”);;
msg.Subject = “My Subject”;
msg.Body = “My Body”;

msg.IsBodyHtml = true;

SmtpClient smtpClient = new SmtpClient(“yourmailserveraddressorip”);

smtpClient.Send(msg);

}

As you can see, pretty close but a few subtle differences. No more warnings! 🙂

** Note that if you really want a good SendMail function, you should pass in the parameters and have overloads for options such as HTML mail, etc. Depending
on the app I am making, I’ll just throw up a email method like this, but it’s really the quick and dirty way to do it. **

Categories
Geeky/Programming

.NET: Redirect URI cannot contain newline characters.

if you are doing a Response.Redirect, and are seeing this error, try something like this

string url = someUrlWithNewLines;

url.Replace(“nr”, “”)

Response.Redirect(url);

Seems trivial, but I have seen the error crop up many times. Just for kicks I did a Google search on it, and a lot of people are asking about it, but no real answer. So, here it is 🙂

Categories
Life

Professor Nova – BCIS .NET Class

Last week, I had the pleasure of “guest lecturing” at SCSU (my alma mater) – To the BCIS .NET Class. The first class, was ASP.NET Basics. The second was extending ASP.NET to connect to a database, which we created a mock employee directory in about 40 minutes. The experience was good for me and hopefully the students as well. I kind of got to see how they are doing things in BCIS (I am a CSCI grad), and also they got to ask questions and go through some real world situations and learn from me. Hopefully they take something away with them they can use in the future.

Categories
Geeky/Programming

Unit Testing Verisign Payflow Pro with VS2005

When you set up payflow pro on a system, you usually are going to use it through the web, you usually dump the certs folder into the inetsrv folder and it works fine. Thing is, when you are using VS2005 Unit Testing, you arent on the web, you can even try setting an HttpContext, but that still doesnt work, you end up with:

Get error “RESULT=-31&RESPMSG=The certificate chain did not validate, no local certificate found, Cert Path = certs, Working Directory = C:ProjectsMyProjectTestResultsuser.name_COMPUTERNAME DateTimeOut”

before you make your request in your tests, do this:
System.Environment.SetEnvironmentVariable(“PFPRO_CERT_PATH”, “c:certs”, EnvironmentVariableTarget.Process);

Copy your certs directory to your C: drive, or you can set the path wherever – mostly likely you would want to add it to your test project, and then set the path when you setup your environment variable as releative to your project.

When you run your unit tests again, you should see a valid response and the request to Verisign should go through correctly.

Categories
Geeky/Programming

Caching got you down? Try an Object Lock

If you are using caching in ASP.net, and when your cache invalidates, you see some really bad performance or race conditions, you probably need to implement object locks.

Categories
Geeky/Programming

CruiseControl.NET – Customize Your Project List with .NET Remoting

I had a need to customize a cc.net project list, and if you install CCTray, in c:Program Filescctray you will see 3 dll’s.

ThoughtWorks.CruiseControl.CCTrayLib
ThoughtWorks.CruiseControl.Remote
NetReflector

Note: If you have the latest CCTray installed, then you will have to develop any custom application in .NET 2.0

So first this, you need to reference those 3 dll’s, and add a using statement to your code

.csharpcode { font-size: small; color: black; font-family: Courier New , Courier, Monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

using ThoughtWorks.CruiseControl.CCTrayLib.Configuration;
using ThoughtWorks.CruiseControl.CCTrayLib.ServerConnection;
using ThoughtWorks.CruiseControl.Remote;
RemoteCruiseManagerFactory factory = new RemoteCruiseManagerFactory();
ICruiseManager manager = factory.GetCruiseManager("tcp://buildserver:21234/CruiseManager.rem");
ProjectStatus[] projectStatuses = manager.GetProjectStatus();
foreach (ProjectStatus status in projectStatuses)
{             
//status.Name; = Project Name
    //status.WebURL; = Web URL for the cc.net project
    //status.BuildStatus.ToString(); = cc.net build status
}

Well, I spent more time trying to format the code on this post than actually coding the program, so that stinks. I wish it wasnt such a pain to preserve formatting

Categories
Geeky/Programming

.NET Execute Process with Arguments

if you are trying to execute a process in .net and trying to pass in arguments, and seem to not be getting anywhere, in the “start info”, set UseShellExecute = false. Worked for me 🙂

Categories
Geeky/Programming

.NET Framework Mistake

I think the .NET Framework is great. It is great for web and fat client apps, web services, etc. I think the mistake Microsoft made with it, is it isn’t required with the OS. Too many people don’t have it. It isn’t feasible to develop a fat client app with .NET and expect widespread installations. People that don’t have the framework will be put of by the whopping ~23MB size of the install. I think it is just goofy that Microsoft tries to push .NET down our throats (as developers) – everything is .NET this, .NET that – and it is good, it can do a lot. Thing is – if you want to get an application to the masses, you still have to fall back on C/C++ as it will 99.9% run natively.

Instead of making the .NET framework a optional update on Windows Update, I think that if it was a required update, it would make things a lot better in terms of developers wanting to target a larger audience. Microsoft says that Vista will have .NET Framework 2.0 – but it is too late. Too many people have XP (9X even!) that they will probably never switch to Vista.

I think managed code is good. I don’t think I should have to develop in unmanaged code because it is too much of a PITA to get the framework to end user machines.

🙂

Categories
Geeky/Programming

PocketBlogger 1.3 Released

I just released PocketBlogger 1.3 which adds support for MSN Spaces. Here is my post over at pocketblogger.net if anyone is interested

Version 1.3 Released (MSN Spaces Support)