Rob Kraft's Software Development Blog

Software Development Insights

A way to eliminate the foreign language Dlls in Silverlight

Posted by robkraft on April 27, 2010

If you compile silverlight projects you may notice that you get 8 non-english language versions of your DLL. Although this causes no major harm, I personally prefer not to create them because it takes time, it clutters up the results of my nant build output, and I don’t need them. To eliminate the the eight foreign language DLLs from your build process, go to your silverlight libraries folder which is probably C:\Program Files\Microsoft SDKs\Silverlight\v3.0\Libraries\Client, and delete the eight subfolders (de, es, fr, it, ja, ko, zh-Hans, and zh-Hant). With the Visual Studio 2010 install, it looks like you also need to delete the same subfolders from C:\Program Files\Reference Assemblies\Microsoft\Framework\Silverlight\v3.0.

Posted in Visual Studio 2010 | Tagged: | Leave a Comment »

Upgrading your nant deploy to IIS from .Net 2 to .Net 4

Posted by robkraft on April 27, 2010

For a few hours I struggled to figure out how to change my nant build process to specify that my web application should be .Net 4.0 instead of .Net 2.0. We use nant to deploy our web site after we build it using the MKIISDIR tag and executing aspnet_compiler. I made sure we were using the 4.0 version of the aspnet_compiler but the site was still defaulting to 2.0.50727. Finally, as I lay in bed about to fall asleep that night, the solution revealed itself to me. I don’t need to change anything in my nant build process; I just need to change the Default Web Site in IIS on the DeployTo server to be 4.0.30319 instead of 2.0.50727.

Posted in Dev Environment | Tagged: , , | Leave a Comment »

Fiddler DOES work on your local/cassini/webdevserver/Visual Studio sites

Posted by robkraft on April 7, 2010

If you want to use Fiddler to monitor against the web traffic on your localhost when running in Visual Studio, change your URL to start with ipv4.fiddler: 

http://ipv4.fiddler:2296/Default.aspx

instead of

http://localhost:2296/Default.aspx

Posted in Visual Studio 2005, Visual Studio 2008 | 2 Comments »

HTML target= is deprecated

Posted by robkraft on April 4, 2010

I learned this weekend that the handy target= attribute for links (<a>) in html is deprecated.  It is so prevalent for opening new windows that I find it hard to imagine that they will remove it from HTML5.  Anyway, I guess we should use javascript window.open instead. https://developer.mozilla.org/en/DOM/window.open

Posted in Code Design | Leave a Comment »

April Edition of DevConnections online

Posted by robkraft on April 4, 2010

You can view the April 2010 edition of DevConnections online at http://viewer.zmags.com/publication/e152a72b#/e152a72b/1

Posted in Magazine Online | Leave a Comment »

Run the same C# program in a Console or a Windows Form

Posted by robkraft on March 9, 2010

I’ve seen a few complicated solutions for writing a C# application to run as both a console application and a windows application, but I’d like to share a simpler example.

  1. Create a new project by selecting a C# “Windows Forms Application”.  This will add references to the project and some starter code necessary for displaying the windows part of your program.
  2. Choose the “Application” tab from your project properties, and set the “Output type” equal to “Console Application”.  This will cause your program to start out running as a console app.
  3. The program I am creating here is a shell to allow you to call the same logic (perhaps generate the SQL Script for a table) and send the script out to the console or have it display in a text box on a form.
  4. Change the Main method in Program.cs to accept the command line arguments as input:
  5.  

[STAThread]
static void Main(string[] commandLineArgs
{
    if (commandLineArgs.Length > 0) //then we have command line args
    {
        Console1.ProcessCommandLineArgs(commandLineArgs);
    }
    else
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form1());
    }
}

5. For this example, I created 2 classes in addition to Form1 which was created for me.  I created a class called MyScripter.cs, which has all the code to “do the work”.  And I created Console1.cs.  I will have code in both Console1.cs and in Form1.cs that can call MyScripter.cs.  Here is the simple console class:

public class Console1
{
    public static void ProcessCommandLineArgs(string[] commandLineArgs)
    {
        MyScripter scripter = new MyScripter();
        foreach (string tablename in commandLineArgs)
        {
            string output = scripter.ScriptMyTable(tablename);
            Console.WriteLine(output);
        }
    }
}

6. I added two text boxes and a button to Form1.cs along with this event:

private void buttonScript_Click(object sender, EventArgs e)
{
    MyScripter scripter = new MyScripter();
    textBox2.Text = scripter.ScriptMyTable(textBox1.Text);
}

7. Finally, an example of the shell MyScripter.cs, which is where the real work is done:

public class MyScripter
{
    public string ScriptMyTable(string tablename)
    {
        string scriptIGenerate = "This is the script of my table named: " + tablename;
        return scriptIGenerate;
    }
}

8. You can now run this compiled program from a command prompt. If you pass in a command line argument, the program will use that as input to generate output to the console. If no command line argument is provided, the application will display the form you created.

Posted in Code Design, Visual Studio 2005, Visual Studio 2008 | Tagged: , , | Leave a Comment »

Analogy – Estimating Software development is like estimating drive times

Posted by robkraft on February 12, 2010

Estimating a software development project is a little like estimating driving time.  If you are estimating something you do over and over, like your drive to and from work, then you can provide estimates that are very accurate.  However, there is always a chance for unexpected traffic jams and bad weather that could unexpectedly make your estimate grossly inaccurate.
When estimating a trip that you have not taken before, the accuracy of the estimate decreases with your knowledge of the possible paths and the accuracy also decreases with longer distance.  Is it not the same with software?  Our estimates become less accurate when there are more things we need to do that we are not familiar with, and as the scope of the project increases.

Posted in Estimating | Leave a Comment »

Redirect to www.webhost4life.com/firewall.htm

Posted by robkraft on February 8, 2010

If you attempt to access a web site that exists on the web host webhost4life.com, and that web site has the SecurityGuard firewall set to High (the default), you may get blocked and redirected this page http://www.webhost4life.com/firewall.htm
This does not occur for all users, but only for those that have a large UserAgent. The UserAgent is the information that your browser sends to every web site when connecting to let the web site use that data to potentially customize what is sent to you and to track data about who is connecting to the site.
If you want to see what is in your user agent, just go to http://whatsmyuseragent.com.
There are two ways I know of to get this to work. One is to have the owner of the web site change the SecurityGuard setting to Medium. I have done this on one of my sites I host on webhost4life. The security risk is really quite small for most sites. The other fix is to uninstall some software from your computer so that your useragent is smaller. Unfortunately there is really not much you can uninstall that affects your user agent.
You might also try a different browser. I noticed that I can access sights blocked by SecurityGuard using Firefox instead of IE because FireFox, in my case, sends a much smaller UserAgent.

Posted in Web Sites | Tagged: , | Leave a Comment »

Eliminating some of the foreign language resource files

Posted by robkraft on February 8, 2010

I’m all in favor of the use of resource files for strings and other elements of our programs, but I don’t like seeing all the subfolders for various foreign language resource builds in projects where I will never need them.
Our Silverlight projects were creating 8 foreign language subfolders (de, es, fr, it, ja, ko, zh-Hans, and zh-Hant). Not only does this clutter my hard drive, complicate my version control, and annoy me; but it requires a little longer to compile, and it nearly doubles the size of my nant output log. I know that it doubles the size because when I caused it to stop, the log file size was cut in half.
I managed to stop the creation of all the foreign language resource versions of the files by deleting the foreign language subfolders with those names from C:\Program Files\Microsoft SDKs\Silverlight\v3.0\Libraries\Client.

Posted in Visual Studio 2008 | Tagged: , , | Leave a Comment »

When CopyLocal=True means CopyLocal=False

Posted by robkraft on February 8, 2010

We have learned that CopyLocal = true is misleading. CopyLocal is set to true by default, but that does not always cause the DLL to get included in the .xap. However, if you change it to false, then back to true, it does get included in the .xap. We have experienced this many times in VS2008 with Silverlight 3.

Also, after you do this, you will notice that it does cause a change in the .csproj file. It sets the Private Tag explicitly to true, rather than relying on the msbuild default value of true.
I hope this post helps others resolve this xap file problem more quickly.

Posted in Visual Studio 2008, Visual Studio 2010 | Tagged: , | Leave a Comment »

 
Design a site like this with WordPress.com
Get started