Saturday, September 12, 2009

Creating A setup For a Windows Application

Creating A setup For a Windows Application

Some one has asked me today that how can I create a setup for a windows application in VB.Net so in order to answer the question I have prepared an article which I am sharing with you all hoping it will be of any help to others to running into the same problem.

The one thing I would like to clear is that creating setup for a windows application is not based on any language.

We need to follow the following Steps, in order to create a setup project for any windows application regardless of the language.

1. Open visual studio.
2. Select New Project from the File Menu.
3. Under The Other Project Types.
4. Select Setup Project.
5. Name it I am using Setup1 for the Example.














6. Once You Click Ok You will see the Screen Like This














7. Select Application Folder in Left Tab under File System on Target Machine.
8. Right Click on it.














9. Under Add option you will find the Folder, File, Assembly options. Choose the appropriate option I am Directly Creating an exe File you may also Create a folder and in that folder Cerate the exe file.
10. Now Browse for the EXE. For which you want to create setup


11. The Dependent DLL’s and the Exe will be copied


12. If you want to create Shortcut keys on the user Desktop and in the Program files Then Right Click On the Exe File


13. Choose Create shortcut. Rename It.


14. Now Drag and Drop This Shortcut To the Appropriate folder


15. Now Some Properties We Need to Change In order that they look like this is ours company Project.
16. Select The Project from the Solution Explorer and Press Select the Project from the Solution Explorer and Press to open the Properties.


17. Change The Author Name From The Default Company Name to the name of your choice.
18. And Manufactures Name


19. Choose Release Option Instead of Debug option


20. And Then Build Solution


21. Now Your Product is ready to distribute with the setups.You Can See That by Opening the Containing Folder


22. There In Setup  setup Relase you will find two files To distribute.

Friday, September 11, 2009

Solution to: URI Formats Not Supported

I am Sending a Mail with attachemts for this I have Made A WCF Which works fine when I give the Network path of the file. but I need to host It And when I try to give a URL path It Says. URI format not supported please Help My Code in WCF

public List funSendMail(Mailcls m)
{
List result = new List();
try
{
/* Create a new blank MailMessage with the from and to adreesses*/
System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage(m.Sender, m.Receiver);
/*Checking the condition that the cc is empty or not if not then
* include them
*/
if (m.Cc != null && m.Cc != string.Empty)
{
mailMessage.CC.Add(m.Cc);
}
/*Checking the condition that the Bcc is empty or not if not then
* include them
*/
if (m.Bcc != null && m.Bcc != string.Empty)
{
mailMessage.Bcc.Add(m.Bcc);
}
//Ading Subject to the Mail
mailMessage.Subject = m.Subject;
//Adding the Mail Body
mailMessage.Body = m.Body;
/* Set the properties of the MailMessage to the
values on the form as per the mail is HTML formatted */
mailMessage.IsBodyHtml = true;

/* Bigining of Attachment1 process &
Check the all file for a attachment */
if ((m.AttachfilesPath != null) && (m.AttachfilesPath.Count > 0))
{
foreach (string s in m.AttachfilesPath)
{
result.Add("Attaching File : " + s);
System.Net.Mail.Attachment attach = new System.Net.Mail.Attachment(s);
/* Attach the newly created email attachment */
mailMessage.Attachments.Add(attach);
}
}
/* Set the SMTP server and send the email with attachment */
System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient();
// smtpClient.Host = emailServerInfo.MailServerIP;
//this will be the host in case of gamil and it varies from the service provider
smtpClient.Host = m.Host;
//smtpClient.Port = Convert.ToInt32(emailServerInfo.MailServerPortNumber);
//this will be the port in case of gamil for dotnet and it varies from the service provider
smtpClient.Port = m.Port;
smtpClient.UseDefaultCredentials = true;
//smtpClient.Credentials = new System.Net.NetworkCredential(emailServerInfo.MailServerUserName, emailServerInfo.MailServerPassword);
smtpClient.Credentials = new System.Net.NetworkCredential(m.UserName, m.Password);
//this will be the true in case of gamil and it varies from the service provider
smtpClient.EnableSsl = m.SSL;
smtpClient.Send(mailMessage);
try
{
/* Delete the attachements if any */
foreach (string s in m.AttachfilesPath)
{
File.Delete(s);
}
}
catch { }
result.Add("1");
}
catch (Exception ex)
{
result.Add("-2 " + ex.Message);
}
return result;
}

and In Calling Appication (Which is a Silverlight Application)


ObservableCollection cv = new ObservableCollection();
//cv.Add(@"file://c6/Shared/Repo/a/Drafts/go.png%22);//This Works
cv.Add(@"http://www.msdotnetmentor.com/wp-content/uploads/2009/08/5.JPG%22);//This Doesnot Work
Mail.Bcc = txtBCC.Text;
Mail.Body = txtMailBody.Text;
Mail.Cc = txtCC.Text;
//Mail.AttachfilesPath = SendDraftAttachment;
Mail.AttachfilesPath = cv;
Mail.Host = EditDeleteEmailConfig.SMTPHost;
Mail.Password = EditDeleteEmailConfig.SMTPPassword;
Mail.Port = EditDeleteEmailConfig.SMTPPort;
Mail.Receiver = txtTo.Text;
Mail.Sender = txtFrom.Text;
Mail.SSL = EditDeleteEmailConfig.SMTPSSL;
Mail.Subject = txtSubject.Text;
Mail.UserName = EditDeleteEmailConfig.SMTPUserName;
SuccessMessage = "Mail Sent Successfully";
ErrorMessage = "Error In Sending Mail" + Environment.NewLine + "Try Sending Later";
if (EmailSettings)
{
SendClient.funSendMailAsync(Mail);
SendClient.funSendMailCompleted += new EventHandler(SendClient_funSendMailCompleted);
}
else
{
EditDeleteEmailConfig = new EmailConfig();
IsSendMail = true;
EmailSettingsClient.GetEamilConfigByClientIdAsync(userID);
}

Fine I got The Answer
Points:
1. URI is not a physical path so it can't be used for File Handling as we need the Physical path for that.
2. There is nothing in WCf like server.mappath()
3. we have to do some workaround to achive so and that work around is
add the following Namespaces :
using System.ServiceModel.Activation;
using System.Web;

now the class implementing the intervfce or the WCF class Use This Line of Code

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]

Eg:

// NOTE: If you change the class name "SendMailWCF" here, you must also update the reference to "SendMailWCF" in App.config.
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class SendMailWCF : ISendMailWCF
{
and now you can access the file like

string RD = HttpContext.Current.Server.MapPath("Repo") + @"\" + filename;
And below is an excerpt from the web.config.

<!-- Added only the one line below -->
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> <!-- Everything else was left intact --> <behaviors> <!-- ... --> </behaviors> <services> <!-- ... --> </services>

Thanks and Regards
Meetu Choudhary
http://www.msdotnetheaven.com/forums/index.php
http://www.msdotnetmentor.com/
http://aspnetbymeetu.blogspot.com/

URI Format Not Supported.

I am Sending a Mail with attachemts for this I have Made A WCF Which works fine when I give the Network path of the file. but I need to host It And when I try to give a URL path It Says. URI format not supported please Help My Code in WCF

public List funSendMail(Mailcls m)
        {
            List result = new List();
            try
            {
                /* Create a new blank MailMessage with the from and to adreesses*/
                System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage(m.Sender, m.Receiver);
                /*Checking the condition that the cc is empty or not if not then
                 * include them
                 */
                if (m.Cc != null && m.Cc != string.Empty)
                {
                    mailMessage.CC.Add(m.Cc);
                }
                /*Checking the condition that the Bcc is empty or not if not then
                 * include them
                 */
                if (m.Bcc != null && m.Bcc != string.Empty)
                {
                    mailMessage.Bcc.Add(m.Bcc);
                }
                //Ading Subject to the Mail
                mailMessage.Subject = m.Subject;
                //Adding the Mail Body
                mailMessage.Body = m.Body;

                /* Set the properties of the MailMessage to the
                   values on the form as per the mail is HTML formatted */

                mailMessage.IsBodyHtml = true;


                /* Bigining of Attachment1 process   & 
                   Check the all file for a attachment */

                if ((m.AttachfilesPath != null) && (m.AttachfilesPath.Count > 0))
                {
                    foreach (string s in m.AttachfilesPath)
                    {
                        result.Add("Attaching File : " + s);
                       
                        System.Net.Mail.Attachment attach = new System.Net.Mail.Attachment(s);                        
                        /* Attach the newly created email attachment */
                        mailMessage.Attachments.Add(attach);
                    }

                }

                /* Set the SMTP server and send the email with attachment */
                System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient();
                // smtpClient.Host = emailServerInfo.MailServerIP;
                //this will be the host in case of gamil and it varies from the service provider
                smtpClient.Host = m.Host;
                //smtpClient.Port = Convert.ToInt32(emailServerInfo.MailServerPortNumber);
                //this will be the port in case of gamil for dotnet and it varies from the service provider
                smtpClient.Port = m.Port;
                smtpClient.UseDefaultCredentials = true;
                //smtpClient.Credentials = new System.Net.NetworkCredential(emailServerInfo.MailServerUserName, emailServerInfo.MailServerPassword);
                smtpClient.Credentials = new System.Net.NetworkCredential(m.UserName, m.Password);
                //this will be the true in case of gamil and it varies from the service provider
                smtpClient.EnableSsl = m.SSL;
                smtpClient.Send(mailMessage);

                try
                {

                    /* Delete the attachements if any */
                    foreach (string s in m.AttachfilesPath)
                    {
                        File.Delete(s);
                    }
                }
                catch { }
                result.Add("1");

            }
            catch (Exception ex)
            {
                result.Add("-2 " + ex.Message);
            }
            return result;

        }
and In Calling Appication (Which is a Silverlight Application)


ObservableCollection cv = new ObservableCollection();
            //cv.Add(@"\\C6\Shared\Repo\a\Drafts\go.png");//This Works
            cv.Add(@"www.msdotnetmentor.com/wp-content/uploads/2009/08/5.JPG");//This Doesnot Work
            Mail.Bcc = txtBCC.Text;
            Mail.Body = txtMailBody.Text;
            Mail.Cc = txtCC.Text;
            //Mail.AttachfilesPath = SendDraftAttachment;
            Mail.AttachfilesPath = cv;
            Mail.Host = EditDeleteEmailConfig.SMTPHost;
            Mail.Password = EditDeleteEmailConfig.SMTPPassword;
            Mail.Port = EditDeleteEmailConfig.SMTPPort;
            Mail.Receiver = txtTo.Text;
            Mail.Sender = txtFrom.Text;
            Mail.SSL = EditDeleteEmailConfig.SMTPSSL;
            Mail.Subject = txtSubject.Text;
            Mail.UserName = EditDeleteEmailConfig.SMTPUserName;
            SuccessMessage = "Mail Sent Successfully";
            ErrorMessage = "Error In Sending Mail" + Environment.NewLine + "Try Sending Later";
            if (EmailSettings)
            {
                SendClient.funSendMailAsync(Mail);
                SendClient.funSendMailCompleted += new EventHandler(SendClient_funSendMailCompleted);
            }
            else
            {
                EditDeleteEmailConfig = new EmailConfig();
                IsSendMail = true;
                EmailSettingsClient.GetEamilConfigByClientIdAsync(userID);
            }



Now The Solution IS


Fine I got The Answer

Points:
1. URI is not a physical path so it can't be used for File Handling as we need the Physical path for that.
2. There is nothing in WCf like server.mappath()
3. we have to do some workaround to achive so and that work around is

add the following Namespaces :
using System.ServiceModel.Activation;
using System.Web;


now the class implementing the intervfce or the WCF class Use This Line of Code
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]


Eg:
// NOTE: If you change the class name "SendMailWCF" here, you must also update the reference to "SendMailWCF" in App.config.
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class SendMailWCF : ISendMailWCF
{


and now you can access the file like
string RD = HttpContext.Current.Server.MapPath("Repo") + @"\" + filename;



And below is an excerpt from the web.config.



<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> <behaviors> </behaviors> <services> </services>

Saturday, August 29, 2009

Scour Friend Invite

Hey,

Check out: http://scour.com/invite/meetu.choudhary/

I'm using a new search engine called Scour.com. It shows Google/Yahoo/MSN
results and user comments all on one page. Best of all we get rewarded for
using it by collecting points with every search, comment and vote. The
points are redeemable for Visa gift cards. Join through my invite link so we
can be friends and search socially!

I know you'll like it,
- MeetuChoudhary

This message was sent to you as a friend referral to join scour.com, please
feel free to review our http://scour.com/privacy page and our
http://scour.com/communityguidelines/antispam page.
If you prefer not to receive invitations from ANY scour members,
please click here - http://www.scour.com/unsub/e/bWVldHVjaG91ZGhhcnkubWVldEBibG9nZ2VyLmNvbQ==

Write to us at:
Scour, Inc., 15303 Ventura Blvd. Suite 220, Sherman Oaks, CA 91403, USA.

campaignid: scour200908290001
Scour.com

Subscribe via email

Enter your email address:

Delivered by FeedBurner

MSDotnetMentor

MSDotnetMentor My Website http://msdotnetmentor.com