How To Fix Archives - Page 9 of 12 - Digital Tool Factory blog How To Fix Archives - Page 9 of 12 - Digital Tool Factory blog

The Digital Tool Factory Blog

How to Fix “Cannot Publish Because a Project Failed to Build” error

VS2010_Beta1_ScreenShotThe Problem: You attempt to publish your C# ClickOnce application in Visual Studio 2010, but you get the “How to Fix “Cannot Publish Because a Project Failed to Build” error” error. There are no syntax errors.

The Cause: No idea

The Solution: Simply right click on the solution in the Solution Explorer, and click “Publish” – no idea why that works, but it does.

Creative Commons License photo credit: sarnil

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


01
Oct 10


Written By Steve French

 

How to fix the Asp.net CalendarExtender and CompareValidator to accept European date formats

The Problem: You want to use the standard European Date Format, DD/MM/YYYY instead of the American Date Format MM/DD/YYYY.  You change the “Format” feature of the CalendarExtender to “DD/MM/YYYY”, but then the CompareValidator (which you’re using to ensure valid dates) calls out that you have entered an invalid date.

The Cause: The Compare Validator is expecting a different date format than it receives, and throws the error.   You will then notice that there is no “Format” attribute on the CompareValidator.

The Solution: Add the following line to the System.Web portion of your web.config file.

<globalization culture=”fr-FR”/>

That’s it!

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


01
Oct 10


Written By Steve French

 

How to fix the “could not load file or assembly microsoft.sqlserver.batchparser” error

database schemaThe Problem: Every time you attempt to run Microsoft’s excellent Database Publishing Wizard Utility you get the following error after you enter your login information could not load file or assembly microsoft.sqlserver.batchparser

The Cause: This problem can be taken literally – Microsoft.SqlServer.Batchparser is not installed on your computer.

The Solution: Go To this link on the Microsoft site and download the Microsoft SQL Server 2005 Management Objects Collection. Then install the MSI

That’s it!

For those of you who are not familiar with the tool, the Database Publishing Wizard is a free tool Microsoft made which allows you to generate sql scripts of existing databases, which speeds up moving them around on third party hosting better than any other method.

Creative Commons License photo credit: gnizr

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


30
Sep 10


Written By Steve French

 

How to fix problems with the placeholder control and custom web user controls

The Problem: You are using an asp.net PlaceHolder control and populating it with a collection of custom web controls.  You then get “Null Reference Exception” and “Are you missing an assembly?” errors.  Your code looks much like this

foreach (string str in strStringList)
{
CustomWebBox cb=new CustomWebBox()[
cb.CustomTitle=str;
myPlaceHolder.Controls.Add(cb);
}

The Cause: The same ID’s are being used over and over agian in the page as the web control repeats.

The Solution: Instead of simply reinitializing the control the “new” keyword, load it manually using Page.LoadControl.  That keeps the id tags different and the error is avoided.  Your code would look something like this.

foreach (string str in strStringList)
{
CustomWebBox cb=(CustomWebBox)Page.LoadControl("~/CustomWebBox.ascx");
cb.CustomTitle=str;
myPlaceHolder.Controls.Add(cb);
}

That’s it!

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


27
Sep 10


Written By Steve French

 

How To Fix Column Doubling in an ASP.net GridView – with Code Sample

Chocolate Tools
The Problem: You are trying to create an ASP.net GridView that automatically populates on any dataset, as well as automatically sorts, but for some reason whenever you click the headers to sort the GridView, the data doubles.

The Cause: I originally omitted crucial line
gv.Columns.Clear();

in the code sample below.    For whatever reason I got it stuck in my head that the data was doubling, not the columns.

Continue reading →


31
Aug 10


Written By Steve French

 

Silverlight Tip – How to make bold text in a textblock from the CodeBehind

The Problem: You need to conditionally bold text in a text block, but you cannot find any way of doing so

The Cause: For inexplicable reasons, Microsoft chose not to include a FontWeight.Bold in their xaml specification

The Solution: Microsoft did include a FontWeights (note the S) class  To bold text in the codebehind, all you have to do is write this

tbbDownloader.FontWeight = FontWeights.Bold;

And presto!  Bold Text.

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


27
Jul 10


Written By Steve French

 

How to fix a missing reference to mscorlib in Visual Studio 2010

Runtime compiling is greatI was trying to update my main app code to utilize the .Net Framework 4.0 and this happened:

The Problem: I could find no obvious way to update the mscorlib reference in my solution, so I decide to simply delete it and add it again, and hope that it magically updates to the most recent version.  This is actually what usually happens with Visual Studio.  However, I delete the mscorlib reference, and I am unable to add it back again, I get the error message telling me that mscorlib is already included in the project.

The Cause: This is a known problem in Visual Studio.

The Solution: I just went into my project (.csproj) file and added the following line

<Reference Include=”mscorlib” />

And that fixed it.  I still have no idea how to make it use the most recent .Net Framework though.

Creative Commons License photo credit: dasapfe

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


26
Jul 10


Written By Steve French

 

A simple way to create a Microsoft Word document from a template in Asp.net/C#

Will code for food I recently had the need to create a Microsoft Word document from a template. I initially tried using Office Web Components and Interop but all that really wasn’t worth the trouble.  I wound up doing global replacements in the html of html   Here is how I did it:

  1. Open up your template document in word, and put any target areas in special Brackets, the text would read something like “I, [FULLNAME] do hereby affirm that”.  I found that the target area had to be in uppercase, I’m not sure why
  2. Go to “Save As Html, Filtered”, and save it in a writeable directory.
  3. In your C# code, first load the entire document into a string
  4. Convert that string into an instance of StringBuilder
  5. Use the StringBuilder Replace function, it would look something like this –  sb.Replace(“[FULLNAME]”, strFullName);
  6. Create a TextWriter, and write the StringBuilder to it – make sure you’re saving it with a “.doc” extension.
  7. Close the TextWriter

All told, the code looks like this

//Create a new filename
string strFileName = System.Guid.NewGuid().ToString();
string strPathRoot = “d:domainsMyDomainWord”;
string strPath = strPathRoot + “TemplateHtml.doc”;
string str = System.IO.File.ReadAllText(strPath);
StringBuilder sb = new StringBuilder();
sb.AppendLine(s);
//replace the text
sb.Replace(“[FULLNAME]”, strFullName);
//save it out
TextWriter tw = new StreamWriter(strPathRoot + strFileName + “.doc”);
// write a line of text to the file
tw.WriteLine(sb.ToString());
// close it
tw.Close();
tw.Dispose();

That’s it!

Creative Commons License
photo credit: pvera

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


06
Jul 10


Written By Steve French

 

How to fix the “The service cannot be activated because it requires ASP.NET compatibility” error

The Problem: You try to access your web service on IIS 7 and you get the following error

The service cannot be activated because it requires ASP.NET compatibility. ASP.NET compatibility is not enabled for this application. Either enable ASP.NET compatibility in web.config or set the AspNetCompatibilityRequirementsAttribute.AspNetCompatibilityRequirementsMode property to a value other than Required.
at System.ServiceModel.Activation.HostedAspNetEnvironment.ValidateCompatibilityRequirements(AspNetCompatibilityRequirementsMode compatibilityMode) at System.ServiceModel.Activation.AspNetCompatibilityRequirementsAttribute.System.ServiceModel.Description.IServiceBehavior.Validate(ServiceDescription description, ServiceHostBase serviceHostBase) at System.ServiceModel.Description.DispatcherBuilder.ValidateDescription(ServiceDescription description, ServiceHostBase serviceHost) at System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost) at System.ServiceModel.ServiceHostBase.InitializeRuntime() at System.ServiceModel.ServiceHostBase.OnBeginOpen() at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open() at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath) at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)

Continue reading →


15
Jun 10


Written By Steve French

 

How to fix the “550 Requested action not taken: mailbox unavailable or not local” email problem

Lost: Remote ControlThe Problem: You send an email to someone and get the following back

Your message did not reach some or all of the intended recipients.

Subject:    Any Subject

Sent: 6/4/2010 2:31 PM

The following recipient(s) cannot be reached:

This User on 6/4/2010 2:31 PM

Server error: ‘550 Requested action not taken: mailbox unavailable or not local’

The Cause: Both sender and recipient are on the same mail server, but the recipient’s mail server is hosted by Google Apps (or some other mail server).  Your smtp server makes a preliminary request to the wrong server, and causes this false error message.

The Solution: The recipient (who has the mail server hosted by Google Apps) needs to disable mail services for their domain.  You can do it in IIS directly (assuming you are running Windows).  In Plesk simply go to Domains > Mail > Disable Mail

Creative Commons License photo credit: jaqian

 

This post originally appeared on the Stronico blog – with the absorption of Stronico into Digital Tool Factory this post has been moved to the Digital Tool Factory blog


04
Jun 10


Written By Steve French

 




Copyright 2011 Digital Tool Factory. All Rights Reserved. Powered by raw technical talent. And in this case, WordPress.