Click Once Deployment – Improperly Formatted

Error Message:
Cannot continue. The application is improperly formatted. Contact the application publisher for assistance.

Application validation did not succeed. Unable to continue.
Unable to retrieve application files. Files corrupt in deployment.

Solution:
For every project in your solution,

  1. Close your solution
  2. Open every project file in notepad ( csproj for c# projects )
  3. Look for the ToolsVersion attribute
  4. Make sure all projects are using the same ToolsVersion
  5. Save
  6. Load your solution and deploy.
Note: The Target Framework Framework is not the same as Tools Version

I had searched for hours for a solution, so I hope this helps someone else.




Publishing Using VisualStudio

I have often had the glorious opportunity to watch someone try to deploy a project by picking compiled libraries that they had thought had changed.  Every time they deployed by using this method, their live project would not run.  When they run their project on the development machine, it runs no problem.  This confuses the developer to no end resulting in a multitude of profanities.

This is a bit painful to watch.   I really do not understand why developers do not deploy by using installation packages or deployment methods provided by their development environment.

Today, I had offered to deploy the project for them and used the VisualStudio deployment utility.  This was a web-based project so it was very easy.  The deployment wizard walks you through the process starting at where you would like to deploy to.  The deployment results in only deploying the files necessary to run the program or website.  I had learned this principal while working for a London company; ICINITI.

ICINITI would use a packaging tool to deploy products to customer machines including websites.  Their projects would often automate part of the process including site setup, run batch files and deploy other required files.  Deployment to customer’s computer systems would go pretty quick.  Sometimes it was so smooth the customer was able to conduct the deployments themselves.

Today’s deployment took about 5 minutes or less.   I had later demonstrated how and what I had done.   I believe this will be used a little more often as a deployment technique.

DotNet Windows Form Image Transparency

Recently during a project I had a need to overlay an image on a windows form in order to indicate a status of inability.  This image had a semi-transparency quality as well as a full transparency background.  To my dismay, the semi-transparency rendered in full color and the full transparency background seemed to inherit the parent form, but not show the controls behind it as one would expect.

After sometime of researching the issue, I came to a determination that what I was trying to do could only be done in web development (HTML).  From my research I had assembled some ideas in how to make transparencies work.   I took ideas from several sources and came up with the following.

Step By Step ( see Sample Code )

1. Create a class that extends System.Windows.Forms.Control
2. Place code from sample cod
3. Compile Project
4. Add new control to the Form ( remember this is for a windows application )
5. Set Background Image

Sample Code


protected override CreateParams CreateParams
{
     // Make window transparent
     get
     {
          CreateParams cp = base.CreateParams;
          cp.ExStyle |= 0x20;  // WS_EX_TRANSPARENT return cp;
     }
}

protected override void OnPaintBackground(PaintEventArgs pevent)
{
// Do not paint the background
}

protected override void OnPaint(PaintEventArgs e)
{ 
     // Paint background image 
     if (BackgroundImage != null)
     {
          Bitmap bmp = new Bitmap(BackgroundImage);
          bmp.MakeTransparent(Color.White);
          e.Graphics.DrawImage(bmp, 0, 0, Width, Height);
     }
}

Note:  When you overlay an image – even transparent, you may see the controls behind, but you will not be able to access them.  This is true in both web and windows development.

Javascript equalsIgnoreCase Function

This week’s code sample is JAVASCRIPT based. I found this while researching user validation routines. This function is a javascript version of a common Java function. We have replicated the calling syntax as a java programmer would expect to use it by effectively appending it as a method of the javascript String Object.

For more great scripts: http://www.apriori-it.co.uk

Important Note: Works with IE and FireFox

//The first line assigns the MatchIgnoreCase function as 
//an equalsIgnoreCase method of the String object 

String.prototype.equalsIgnoreCase = MatchIgnoreCase; 

function MatchIgnoreCase(strTerm, strToSearch) 
{ 
	strToSearch = strToSearch.toLowerCase(); 
	strTerm = strTerm.toLowerCase(); 
	if(strToSearch==strTerm) 
	{ 
		return true; 
	} else { 
		return false; 
	} 
}

Hot Keys

alt-1 – Load help

This week’s code sample is JAVASCRIPT based. It traps a keyup event in a web page that contains this code. The function then goes a step further and looks for the Alt key. Once we have the Alt filtered out we can begin to look for key combinations.

Below the code sample shows traping for numeric keys. The key code is actually an ASCII representation, so therefore you will need to know some common ASCII codes. Our example shows 48, 49, 50 being used. This translates to 1, 2, 3. So in short we are making a routine that will trap the following:

  • Alt-1
  • Alt-2
  • Alt-3

Important Note: Works with IE and FireFox

Try the Alt keys.