Josh-CO Dev

Solving the worlds problems one line of code at a time.

Leave a comment

Sending Emails from Silverlight

One of the requirements of my application I am writing is to send emails upon the creation of a new comment. This turned out to be quite simple. I am using RIA services and a Domain Service. In my domain service, I simply added the following code. I have noticed that this does not seem to work through GoDaddy, but it does test fine from my machine.

public string SendEmail(string to, string body, string subject)
MailMessage msg = new MailMessage();
msg.To.Add(new MailAddress(to));
msg.From = new MailAddress(“”);
msg.Body = body;
msg.Subject = subject;
SmtpClient smtp = new SmtpClient();
smtp.Host = “”;
smtp.EnableSsl = true;
smtp.UseDefaultCredentials = false;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Credentials = new System.Net.NetworkCredential(“gmailaccount”, “gmailpassword”);
smtp.Port = 587;
return “Success”;
catch (Exception ex)
return ex.ToString();


Leave a comment

Silverlight Image Source Binding

I figured out something that just happened to be a life saver yesterday. I have been working on a more social tool for my workout tracking program. One thing I wanted was a comment system that would show the user’s profile picture. I spend forever trying to think of a way to loop through the list box. What I ended up with was much more simple:

 Here is the XAML:

<StackPanel Orientation=”Horizontal”>

<Image Grid.Row=”1″ Height=”64″ Source=”{Binding ImagePath}” HorizontalAlignment=”Left” Margin=”5,5,0,0″ x:Name=”imgProfileImage” Stretch=”Fill” VerticalAlignment=”Top” Width=”64″ />


The backend code simply sets the ImagePath binding to a path that is stored in the database.


Leave a comment

Some LinqToSQL Samples to get you through the day

So, one of the things that I am learning from scratch with Silverlight is LinqToSQL. In my professional life, we are still using typed datasets to do all of our databinding and our restricted to WinForms and So this is all new to me. I have found the process to be incredibly simple and thought I would share some code.

Click past the jump for code.

Continue reading

Leave a comment

Silverlight WCF RIA Issues – Implement Domain Service

As i’ve mentioned in previous posts, I have been having some issues with WCF services in Silverlight. On my local computer, my application would compile and run just fine. When I would move the web service out to my host, GoDaddy, I would always get back errors that did not make any sense. I scoured the internet and found nothing of use. I have a clientaccesspolicy.xml, crossdomainpolicy.xml and did everything else the web told me. I then stumbled into some articles about using the entity framework with RIA calls, I am using LinqToSQL. These articles uses a domain services file to interface with the web service. I implemented this and everything began working. The weird thing is, so far it seems that I only need to expose the table itself through the domain service. I can still make all my web service calls, inserts, etc by calling my web service directly. Most frustrating problem ever!

Leave a comment

Why not to use the “delete before publishing feature” in Visual Studio

So, I learned an important lesson yesterday, I narrowly avoided wiping the entire site so far. Not that I have a whole lot of content yet, but it would have been a bit heartbreaking to say the least. I am working on a personal project that involves setting up a subdomain on this site that will host a silverlight application. My web project is set to delete all files and replace them when I perform a publish. Well, I am troubleshooting some issues with a WCF service and posted some files in my root directory. A couple of mistakes later and I accidently tried to publish my project to the root drive rather than the folder that houses my subdomain. Many of my folders and all of my files were wiped from the root directory. Thankfully, I happened to have a backup of most of the files and most all wordpress content is housed in the database. Talk about a rough lesson to learn!