tag:blogger.com,1999:blog-68118477412042267832024-03-05T05:35:25.241+00:00SQL, C# and my coding journey1http://www.blogger.com/profile/14851445048796393664noreply@blogger.comBlogger109125tag:blogger.com,1999:blog-6811847741204226783.post-58109546584923560782015-09-30T11:00:00.000+01:002015-09-30T11:00:06.527+01:00MCSE: Business Intelligence<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvfpqEl_VwpP0N2ATVlaUJjIJESw8Udl-4HnVcigSxomXUNVVIVEnPmm1JZKfislz65GFVse-w_kyJ9M1qIbLHBPpnyAmx4-CqZuNizYtbr6UQ-owrDNAJmpSCZj0wpxTD2k-BHiorgSxj/s1600/MCSE_BI_Blk.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em; text-align: center;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgvfpqEl_VwpP0N2ATVlaUJjIJESw8Udl-4HnVcigSxomXUNVVIVEnPmm1JZKfislz65GFVse-w_kyJ9M1qIbLHBPpnyAmx4-CqZuNizYtbr6UQ-owrDNAJmpSCZj0wpxTD2k-BHiorgSxj/s320/MCSE_BI_Blk.png" width="172" /></a>
<br />
I have just recently finished studying for my <a href="https://www.microsoft.com/en-us/learning/mcse-sql-business-intelligence.aspx">MCSE: Business Intelligence</a> certification and I am pleased to say that I have now passed the two required exams <a href="https://www.microsoft.com/learning/en-gb/exam-70-466.aspx">70-466</a> and <a href="https://www.microsoft.com/learning/en-gb/exam-70-467.aspx">70-467</a>.<br />
<br />
The last exam has to be the hardest Microsoft exam I have taken due to the large range of knowledge required. I can now relax for 3 years before I have to take a recertification exam for this.1http://www.blogger.com/profile/14851445048796393664noreply@blogger.com0tag:blogger.com,1999:blog-6811847741204226783.post-54253141248851182992015-07-22T15:49:00.000+01:002015-07-22T15:50:22.428+01:00MCSA: SQL Server certifications<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiV-fht32kqQzu3mrFOlcZMUzT_hcDzaB7v6EO8tfLJ91AjpnrB2yW83196Aejpeqckm1bVALKa3YWfmfrXoeH8Vj0LFQZXYAKkPMSTB-giORB4oL4BGh7q4e6hRDG5_vhuHX-MtiCTth3S/s320/MCSA_SQL12_Blk.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em; text-align: center;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiV-fht32kqQzu3mrFOlcZMUzT_hcDzaB7v6EO8tfLJ91AjpnrB2yW83196Aejpeqckm1bVALKa3YWfmfrXoeH8Vj0LFQZXYAKkPMSTB-giORB4oL4BGh7q4e6hRDG5_vhuHX-MtiCTth3S/s320/MCSA_SQL12_Blk.png" width="172" /></a>
<br />
I have just recently finished studying for my <a href="https://www.microsoft.com/learning/en-gb/mcsa-sql-certification.aspx">MCSA: SQL Server 2012</a> certification and I am pleased to say that I have passed the three required exams <a href="https://www.microsoft.com/learning/en-gb/exam-70-461.aspx">70-461</a>, <a href="https://www.microsoft.com/learning/en-gb/exam-70-462.aspx">70-462</a> and <a href="https://www.microsoft.com/learning/en-gb/exam-70-463.aspx">70-463</a>.<br />
<br />
Over the next few months I will now to study for the next level, the <a href="https://www.microsoft.com/learning/en-gb/mcse-sql-business-intelligence.aspx">MCSE: Business Intelligence</a>.<br />
<br />1http://www.blogger.com/profile/14851445048796393664noreply@blogger.com0tag:blogger.com,1999:blog-6811847741204226783.post-88104150330098392092015-05-15T09:17:00.000+01:002015-05-15T09:17:45.502+01:00Missing tabs and menu bar in Task ManagerI've just loaded up Task Manager and the tabs and menu bar are missing.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsLirsq7oyPQ9X8uBRQrsRIa6VGzCYodNw-Rf8GgW2Qgmkpkf5ZFaA1913mGrnQsXyft3hZv1YFaI2AWkXPZzLYWnDkrjlmPR7ODhl6PHgZd7I57n3tB2YX4b6kbBLTJVmKpk3Uo7LnVVP/s1600/taskman.PNG" imageanchor="1" style="clear: both; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="209" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsLirsq7oyPQ9X8uBRQrsRIa6VGzCYodNw-Rf8GgW2Qgmkpkf5ZFaA1913mGrnQsXyft3hZv1YFaI2AWkXPZzLYWnDkrjlmPR7ODhl6PHgZd7I57n3tB2YX4b6kbBLTJVmKpk3Uo7LnVVP/s320/taskman.PNG" width="320" /></a></div>
<div style="clear: both;">
To restore the tabs, you need to double click on the outside border of the window.</div>
1http://www.blogger.com/profile/14851445048796393664noreply@blogger.com0tag:blogger.com,1999:blog-6811847741204226783.post-51065194550898812672015-04-24T14:34:00.002+01:002015-04-24T14:34:16.002+01:00Error in any_na(as_list(RHS)) : object 'CanyNA' not foundI'm learning R and playing with the UI and Server components for Shiny.<br />
<br />
A simple example below errors out:<br />
<pre><code>
func = function(input, output){
output$Order<-renderDataTable(
if(is.null(input$Account)|input$Account=="")
{
Order
}else{
Order[AccountNumber==input$Account]
}
)</code></pre>
<br />
The error is<br />
<br />
<code>Error in any_na(as_list(RHS)) : object 'CanyNA' not found</code>
<br />
<code><br /></code><br />
This only started to happen only after I had updated the data.table package.<br />
The resolved this by reinstalling this package.<br />
<br />
<code>install.packages("data.table")</code>1http://www.blogger.com/profile/14851445048796393664noreply@blogger.com0tag:blogger.com,1999:blog-6811847741204226783.post-68147945552948100892015-04-22T08:36:00.001+01:002015-04-22T08:36:20.645+01:00The replacement token 'id' has no valueWhen trying to manually build a NuGet package from the command line with the following command<br />
<br />
<code>nuget pack Trial.nuspec</code><br />
<br />
You may recieve the following error:<br />
<blockquote class="tr_bq">
Attempting to build package from 'Trial.nuspec'.
<br />
The replacement token 'id' has no value.</blockquote>
This will be likely if you are using tokens in the nuspec file. Example:<br />
<pre><?xml version="1.0"?>
<package >
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>$title$</title>
<authors>$author$</authors>
<owners>$author$</owners>
<licenseUrl>http://localhost</licenseUrl>
<projectUrl>http://localhost</projectUrl>
<iconUrl>http://locahost</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<releaseNotes>Initial release.</releaseNotes>
<copyright>Copyright 2015</copyright>
<tags></tags>
</metadata>
<files>
<file src="bin\$configuration$\*" target="" />
</files>
</package></pre>
<br />
If this is the case, run the same command prompt but pass in the csproj file instead.<br />
<br />
<code>nuget pack Trial.csproj</code>1http://www.blogger.com/profile/14851445048796393664noreply@blogger.com0tag:blogger.com,1999:blog-6811847741204226783.post-66079368025024683392015-04-21T14:18:00.000+01:002015-04-21T14:18:56.686+01:00SQL weekday datepart different depending on localeDepending on which language your user is running, the following query will return a different result.<br />
<br />
<code>SELECT DATEPART(weekday, GETDATE())</code>
<br />
<br />
Using the English language (US), this would return 2 if run on a Monday, as Sunday is allocated 1.<br />
If using British English, this would return 1 for Monday, as Sunday is now allocated 7.<br />
<br />
I've just had to write some queries that could be run using either locale. Tested locally it all worked fine. Deployed to live server, all my dates were out. Took me a while to understand that the locale of the user was different.<br />
<br />
I Google'd for an answer and found multiple solution, the one that worked for me was the following:<br />
<br />
<code>SELECT (DATEPART(weekday, GETDATE()) + @@DATEFIRST - 2) % 7 + 1</code><br />
<br />
There are many other solutions to this problem that may be beneficial to others.1http://www.blogger.com/profile/14851445048796393664noreply@blogger.com0tag:blogger.com,1999:blog-6811847741204226783.post-46884984307276975012015-04-20T14:56:00.000+01:002015-04-20T14:56:08.907+01:00SQL Jobs fail when run on a mirrored serverWe have jobs that run on a mirrored server. When these jobs are running on the principal server, no problems, but when they ruin on the mirror nothing works.<br />
Ok, there are several solutions to this problem. Disable jobs on the mirror, but you have to remember to enable these when the mirror fails over and then disable the jobs from the other. Yes you could script this all out.<br />
<br />
The current approach I am using is to add a new step to the job, making it the first step. This executes the following SQL.<br />
<br />
<code>
DECLARE @mirroring_role INT<br />
<br />
SET @mirroring_role = (SELECT mirroring_role FROM msdb.sys.database_mirroring WHERE database_id = db_id('Database Name'))<br />
<br />
IF @mirroring_role = 2<br />
raiserror('The database is running as a mirror',11,1)<br />
</code><br />
<br />
Ensure that you set the steps "On failure action" to "Quit the job reporting success"1http://www.blogger.com/profile/14851445048796393664noreply@blogger.com0tag:blogger.com,1999:blog-6811847741204226783.post-69587002763700125812015-04-15T10:19:00.000+01:002015-04-15T10:20:55.039+01:00Reset to original script directory in PowerShellI've been write several PowerShell scripts lately to help automate repetitive tasks. When I've been testing these scripts, I will often change my current location with in PowerShell, either cd to another location or fire up the SqlServer shell.<br />
<br />
When the script finished during test, I would then make another change, add the next step etc, then go to my PowerShell console, but it's not in the original directory for me to re-run my script.<br />
<br />
I've taken to adding the following to the bottom of my scripts to return the console back to the original location.<br />
<br />
<code>
# Switch back to disk prompt<br />
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition<br />
Set-Location -Path $scriptPath
</code><br />
<br />
I know there are many ways of doing this in PowerShell, but I'm still learning.1http://www.blogger.com/profile/14851445048796393664noreply@blogger.com0tag:blogger.com,1999:blog-6811847741204226783.post-24077686311166845982014-03-19T08:32:00.002+00:002014-03-19T08:32:37.029+00:00Manage User Mapping With ALTER USERI previously posted about how to use the <a href="http://www.jasonlinham.co.uk/2009/05/autofix-db-users.html">SQL stored procs to auto fix a user.</a><br />
<br />
This stored proc is going to be deprecated in new versions of SQL Server. So how do we map a user, we can use the <code><a href="http://technet.microsoft.com/en-us/library/ms176060.aspx">ALTER USER</a></code> function.<br />
<br />
For Example:<br />
<br />
<code>EXEC sp_change_users_login 'Auto_Fix', 'username', NULL, 'password';</code><br />
<br />
now becomes<br />
<br />
<code>ALTER USER [username] WITH LOGIN = [username], PASSWORD = 'password';</code>1http://www.blogger.com/profile/14851445048796393664noreply@blogger.com0tag:blogger.com,1999:blog-6811847741204226783.post-67868143024523976682013-10-28T12:47:00.000+00:002013-11-01T12:48:09.346+00:00Microsoft Certified Solutions Developer: Web Applications<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsJ3WczKpmqRtGrlH-bh-CrkgXrcMK10RcDbo8PFRyBFErIT3fLaTRWhZ3kg927qACuXa_drcAs8MunNq8Xlo36M2O0C2DVXxZcVG1o4V5B5bPZyMfc-s2tN23AtikgrzztU0CjoFzxeeD/s1600/MCSD_2013(rgb)_1477.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em; text-align: center;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsJ3WczKpmqRtGrlH-bh-CrkgXrcMK10RcDbo8PFRyBFErIT3fLaTRWhZ3kg927qACuXa_drcAs8MunNq8Xlo36M2O0C2DVXxZcVG1o4V5B5bPZyMfc-s2tN23AtikgrzztU0CjoFzxeeD/s1600/MCSD_2013(rgb)_1477.png" /></a>
<br />
I would like to say that today I passed my next exam <a href="http://www.microsoft.com/learning/en/us/exam-70-492.aspx">70-492</a>, Upgrade your MCPD: Web Developer 4 to MCSD: Web Applications.<br />
<br />
Over the next few months I will try to blog more, now that I've stopped my studying for the time being.<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
1http://www.blogger.com/profile/14851445048796393664noreply@blogger.com3tag:blogger.com,1999:blog-6811847741204226783.post-62687169047265443012013-06-21T18:15:00.001+01:002015-04-21T21:03:59.043+01:00Microsoft Specialist in Programming in HTML5 with JavaScript and CSS3<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhK-_t-EoHKRRYls53tKcDIBzLDve2_FChuip3CE1PFpMLfyIPU9bRMMoBo06PntJ-yAhIfBU_zBaiBohjrLh0isqQ9abcjCTnEqng55nJR8xBN4KRSPjAQubJ7NdVjfmnPPOZYSiFMeh4s/s1600/MS_2013(rgb)_1485.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em; text-align: center;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsJ3WczKpmqRtGrlH-bh-CrkgXrcMK10RcDbo8PFRyBFErIT3fLaTRWhZ3kg927qACuXa_drcAs8MunNq8Xlo36M2O0C2DVXxZcVG1o4V5B5bPZyMfc-s2tN23AtikgrzztU0CjoFzxeeD/s1600/MCSD_2013(rgb)_1477.png" /></a>
<br />
For my 100<sup>th</sup> post, I would like to say that today I passed the Microsoft Specialist exam <a href="http://www.microsoft.com/learning/en/us/exam-70-480.aspx">70-480</a>, Programming in HTML5 with JavaScript and CSS3.<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
1http://www.blogger.com/profile/14851445048796393664noreply@blogger.com0tag:blogger.com,1999:blog-6811847741204226783.post-26529042683044601732013-04-06T13:15:00.000+01:002015-04-21T21:05:09.609+01:00MCPD Web Developer 4<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhA1otrcGcFTarby4vDkH0kcMzwzIN6Dhpu8iAJtsA1_iWDLgFbgyxgPa5geRfQT_3f3AfoOcW0tyjqXWlVWuqnhO3xB5oZVlunM-lZalFUeMAZ0yjoZ4LFWw4u2cClpJMDeYYHNU5HqLiD/s1600/MCPD(rgb)_1372.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em; text-align: center;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsJ3WczKpmqRtGrlH-bh-CrkgXrcMK10RcDbo8PFRyBFErIT3fLaTRWhZ3kg927qACuXa_drcAs8MunNq8Xlo36M2O0C2DVXxZcVG1o4V5B5bPZyMfc-s2tN23AtikgrzztU0CjoFzxeeD/s1600/MCSD_2013(rgb)_1477.png" /></a>
<br />
Yesterday I successfully passed the upgrade <a href="http://www.microsoft.com/learning/en/us/exam.aspx?ID=70-523">MCPD exam 70-523</a>. Got a great pass mark, so glad that all the studying paid off.<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
1http://www.blogger.com/profile/14851445048796393664noreply@blogger.com0tag:blogger.com,1999:blog-6811847741204226783.post-87901751473168317722013-03-28T09:15:00.001+00:002013-04-07T10:16:50.670+01:00SSIS on 64bit Dev machineYou have an "Execute SQL Task" to return a "Full result set" but when executing you get the following error.<br />
<br />
[Execute SQL Task] Error: Executing the query "SELECT * FROM Table" failed with the following error: "Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.<br />
<br />
Are you running on Windows 7 64bit? A possible fix if you are is to set the run time to 32 bit. You can do this by:<br />
<ol>
<li>Go to Project Properties</li>
<li>Configuration Properties -> Debugging</li>
<li>Set Run64BitRuntime False</li>
</ol>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJLZHmgjwYHEjMspIC-nmcyL2Ayc4gjQs5EsIT8PCvvxznnW9qK_z59hRH5QoOOXPeSn6fOL0Q7miRgm7gcNVvIQEF1oo4Nu0ZXbxnRUayeWqjQtIvDdkizdtVXKrK7Vk268TMuRkk88Te/s1600/ssis-32bit.PNG" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="182" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJLZHmgjwYHEjMspIC-nmcyL2Ayc4gjQs5EsIT8PCvvxznnW9qK_z59hRH5QoOOXPeSn6fOL0Q7miRgm7gcNVvIQEF1oo4Nu0ZXbxnRUayeWqjQtIvDdkizdtVXKrK7Vk268TMuRkk88Te/s320/ssis-32bit.PNG" width="320" /></a></div>
1http://www.blogger.com/profile/14851445048796393664noreply@blogger.com0tag:blogger.com,1999:blog-6811847741204226783.post-19595711207661424742012-10-24T12:42:00.001+01:002012-10-24T12:42:22.163+01:00Visual Studio 2010 not opening CSS filesRecently I have had a problem where Visual Studio 2010 wouldn't open any CSS files. I can't say for sure if this started happening just after I installed SP1 as I don't tend to edit many CSS files.<br />
<br />
The solution I found was to install the following extension.<br />
<code>
Extension Manager -> Online Gallery<br />
</code>
Search for: "Web Standards Update for Microsoft Visual Studio 2010 SP1"<br />
<br />
This information I found on the <a href="http://social.msdn.microsoft.com/Forums/en/vseditor/thread/25f9016c-c790-4b8a-b333-5cfdafe45e2d">social MSDN site here.</a> 1http://www.blogger.com/profile/14851445048796393664noreply@blogger.com0tag:blogger.com,1999:blog-6811847741204226783.post-34280362365479142692012-05-31T15:25:00.000+01:002012-05-31T15:25:01.424+01:00Unit testing MVC routesIf you are using the
MVC Routing engine, you can test your routes to ensure that they work as
expected.<br />
<br />
To test the default route:<br />
<br />
<pre><code>[Test]
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home",
action = "Index",
id = UrlParameter.Optional }
);</code></pre>
<br/>
The example test is:<br />
<br />
<pre><code>[Test]
public void DefaultRouteTest()
{
var routes = new RouteCollection();
var application = new Application();
application.RegisterRoutes(routes);
var context = new Mock<httpcontextbase>();
context.Setup(p => p.Request.AppRelativeCurrentExecutionFilePath)
.Returns("~/");
var routeData = routes.GetRouteData(context.Object);
Assert.AreEqual(((Route)routeData.Route).Url,
"{controller}/{action}/{id}");
Assert.AreEqual("Home", routeData.Values["controller"]);
Assert.AreEqual("Index", routeData.Values["action"]);
}</httpcontextbase></code></pre>
<br />
This came from an original post by Scott Gu, that we had to change slightly. <a href="http://weblogs.asp.net/scottgu/archive/2007/12/03/asp-net-mvc-framework-part-2-url-routing.aspx">http://weblogs.asp.net/scottgu/archive/2007/12/03/asp-net-mvc-framework-part-2-url-routing.aspx</a><br />
<br />
The original code was causing the first parameter to drop the first character. i.e. For the default route, the controller was return 'ome' instead of 'home'.1http://www.blogger.com/profile/14851445048796393664noreply@blogger.com0tag:blogger.com,1999:blog-6811847741204226783.post-68925393314005019192012-04-11T10:22:00.003+01:002015-04-22T08:29:45.318+01:00Profile not available in Web ApplicationUsing the Web Application project, you are unable to use the intellisense on the Profile class. A workaround has been provided by Joe Wrobel in a post build task.<br />
This post build task is called Web Profile Builder and can be <a href="http://webprofile.codeplex.com/releases/view/5460">download here</a>.<br />
The simple approach:
<br />
<ol>
<li>Install the package.</li>
<li>Add the following to your .csproj file<br /><pre><Import Project="$(MSBuildExtensionsPath)\WebProfileBuilder\WebProfileBuilder.targets" /></pre>
</li>
<li>Build project</li>
</ol>
Joe has a more details in his <a href="http://weblogs.asp.net/joewrobel/archive/2008/02/03/web-profile-builder-for-web-application-projects.aspx">post on how to use the build task</a>.1http://www.blogger.com/profile/14851445048796393664noreply@blogger.com0tag:blogger.com,1999:blog-6811847741204226783.post-80596364630120743032012-04-11T10:05:00.000+01:002015-04-21T19:38:50.801+01:00Datatables update function shows an Alert BoxWhen using the jQuery Datatable plugin and jeditable to allow tables to be editable, calling the update function via sUpdateUrl shows an alert box on it's return.<br />
To suppress the alert box, return the same value that was originally passed in.<br />
C# MVC Example:<br />
<pre><code>$('#myDataTable').dataTable().makeEditable({
sUpdateURL: "/Home/UpdateData"
})
public class HomeController : Controller
{
public string UpdateData(int id, string value,
int? rowId, int? columnPosition,
int? columnId, string columnName)
{
//Add code to update cell
return value;
}
}</code></pre>
Code borrowed from <a href="http://code.google.com/p/jquery-datatables-editable/wiki/EditCell">http://code.google.com/p/jquery-datatables-editable/wiki/EditCell</a>1http://www.blogger.com/profile/14851445048796393664noreply@blogger.com0tag:blogger.com,1999:blog-6811847741204226783.post-31131929091233256872012-03-06T10:28:00.000+00:002012-03-06T10:28:34.379+00:00Checkbox validation with the MVC data annotations<p>I've been using MVC3 for a new site and require a check box to be true before continuing. e.g. "Accept T & Cs".</p>
<p>The data annotation have the [Required] attribute for other field types, but this is ignored for check boxes.</p>
<p>You can create your own custom validators. Below is an example for a single check box to ensure it is true.</p>
<pre><code>[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
public class MustBeTrueAttribute : ValidationAttribute
{
public override bool IsValid(object value)
{
return value != null && value is bool && (bool)value;
}
}</code></pre>
<p>You can then add the attribute to your MVC component model</p>
<pre><code>[Display(Name = "I accept the terms and conditions")]
[MustBeTrue(ErrorMessage = "Please accept terms and conditions before continuing")]
public bool AcceptTerms { get; set; }</code></pre>
<p>This solution was discovered on <a href="http://stackoverflow.com/questions/2245185/how-to-handle-booleans-checkboxes-in-asp-net-mvc-2-with-dataannotations">StackOverflow</a></p>1http://www.blogger.com/profile/14851445048796393664noreply@blogger.com2tag:blogger.com,1999:blog-6811847741204226783.post-38103625464908054262012-01-19T12:38:00.000+00:002015-04-22T08:30:59.698+01:00WCF Error - This collection already contains an address with scheme http.This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.<br />
I've found two solutions to this error depending on which version of the .NET framework you are using. You need to update the web.config with the following:<br />
<br />
<h4>
.NET 4.0</h4>
<code><serviceHostingEnvironment multipleSiteBindingsEnabled="true" /></code>
<br />
<br />
<h4>
.NET 2.0 - 3.5</h4>
<pre><code><serviceHostingEnvironment>
<baseAddressPrefixFilters>
<add prefix="http://www.yourdomain.com"/>
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
</code></pre>
1http://www.blogger.com/profile/14851445048796393664noreply@blogger.com0tag:blogger.com,1999:blog-6811847741204226783.post-32317186327827843112012-01-19T10:02:00.002+00:002015-04-21T19:33:52.969+01:00Unknown server tag 'asp:ScriptManager'Currently build a new portal using Ajax for asynchronous calls. Had the following error:<br />
Unknown server tag 'asp:ScriptManager'<br />
<br />
This error has caused me a headache over the last few days. I finally narrowed it down to a missing line in the web.config.<br />
<pre><code>
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI"
assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</controls>
</pages>
</code></pre>
1http://www.blogger.com/profile/14851445048796393664noreply@blogger.com0tag:blogger.com,1999:blog-6811847741204226783.post-27901864879429221492012-01-17T15:30:00.000+00:002012-01-17T15:33:42.280+00:00SetSite failed for package [Visual Studio Class Designer Package]When starting Visual Studio you get a pop up which contains the following error:<br />
The package 'Visual Studio Class Designer package' has failed to load properly. GUID {DD1683A7-5A4C-4234-81B3-A4CC91DBEAC9}<br />
Close Visual Studio.<br />
<br />
Now start Visual Studio with <code>devenv /log</code><br />
<br />
Navigate to the log location, normally:<br />
C:\Users\<em>username</em>\AppData\Roaming\Microsoft\VisualStudio\10.0\ActivityLog.xml
<br />
If this log contains the following entries:<br />
<pre><code>
<entry>
<record>208</record>
<time>2012/01/17 15:06:00.310</time>
<type>Information</type>
<source>VisualStudio</source>
<description>Begin package load [Visual Studio Class Designer Package]</description>
<guid>{DD1683A7-5A4C-4234-81B3-A4CC91DBEAC9}</guid>
</entry>
<entry>
<record>209</record>
<time>2012/01/17 15:06:00.412</time>
<type>Error</type>
<source>VisualStudio</source>
<description>SetSite failed for package [Visual Studio Class Designer Package]</description>
<guid>{DD1683A7-5A4C-4234-81B3-A4CC91DBEAC9}</guid>
<hr>8000ffff - E_UNEXPECTED</hr>
<errorinfo>Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))</errorinfo>
</entry>
<entry>
<record>210</record>
<time>2012/01/17 15:06:00.415</time>
<type>Error</type>
<source>VisualStudio</source>
<description>End package load [Visual Studio Class Designer Package]</description>
<guid>{DD1683A7-5A4C-4234-81B3-A4CC91DBEAC9}</guid>
<hr>8000ffff - E_UNEXPECTED</hr>
<errorinfo>Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))</errorinfo>
</entry></code></pre>
Now start Visual Studio with <code>devenv /ResetSettings</code>
<br />
<br />
If this doesn't work, then repair or re-install Visual Studio.1http://www.blogger.com/profile/14851445048796393664noreply@blogger.com2tag:blogger.com,1999:blog-6811847741204226783.post-14271230076554832152011-12-12T11:59:00.001+00:002011-12-12T11:59:22.088+00:00MSBuild and XmlTransform<p>Using .NET 4.0 you can use the Config Transformation features by which we can maintain multiple configuration files for different environments. To have one of these files built as part of your continuous integration you can use the MSBuild task TransformXml:</p>
<p>An example of the code usage is below:</p>
<pre><code><UsingTask TaskName="TransformXml"
AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll"/>
<Target Name="GenerateConfigs">
<TransformXml Source="Source\Web.config"
Transform="Source\Web.$(Configuration).config"
Destination="Output\Web.config"/>
</Target>
</code></pre>1http://www.blogger.com/profile/14851445048796393664noreply@blogger.com0tag:blogger.com,1999:blog-6811847741204226783.post-35331011146442199762011-12-12T10:50:00.000+00:002011-12-12T10:50:51.456+00:00MSBuild - Non-string data for Inetstp@MajorVersion<p>When using the the Microsoft.Web.Publishing.Tasks.dll library to do the XML Transforms in a Continuous Integration set-up, like TeamCity. You receive an error like below:</p>
<code>[GetProjectWebProperties] error MSB4138: Non-string data was specified at the registry location
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Inetstp@MajorVersion".</code>
<p>If this is the case, ensure that your build scripts are using .NET 4.0. The scripts I had were defaulting to use .NET 3.5 which threw the error.</p>1http://www.blogger.com/profile/14851445048796393664noreply@blogger.com0tag:blogger.com,1999:blog-6811847741204226783.post-45261099937114016962011-11-24T13:08:00.001+00:002015-04-21T19:35:08.110+01:00YAF Polls - You already voted.A user can't vote as it says "You already voted." when you know you haven't voted with this user account. Have you voted though with a different user account from the same machine or the same network?<br />
By default, YAF only lets a user vote if no one using the same IP Address has already voted.<br />
You can turn this feature off in Host Settings -> Features -> Poll Options -> Poll Votes Dependant on IP1http://www.blogger.com/profile/14851445048796393664noreply@blogger.com0tag:blogger.com,1999:blog-6811847741204226783.post-77070689630971978152011-11-07T15:43:00.002+00:002011-11-07T15:43:28.532+00:00Could not load type 'System.ServiceModel.Activation.HttpModule'<br />
Have you started working on a .NET 4.0 project and received the following error?<br />
<blockquote class="tr_bq">
<code>Could not load type ‘System.ServiceModel.Activation.HttpModule’ from assembly ‘System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.</code><code>
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.</code><code>
Exception Details: System.TypeLoadException: Could not load type ‘System.ServiceModel.Activation.HttpModule’ from assembly ‘System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.</code></blockquote>
<br />
If you have, you probably have installed .Net framework 4.0 on IIS and then enable either a .Net 3.0 or 3.5 WCF feature. To fix you need to reconfigure ASP.NET by using the following command depending on the version of ASP.NET you have installed.<br />
<dl><br />
<dt> IIS 32 bit</dt>
<br /><dd><code>%SYSTEMROOT%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis /iru </code></dd><br />
<dt>IIS 64 bit</dt>
<br /><dd><code>%SYSTEMROOT%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis /iru </code></dd></dl>1http://www.blogger.com/profile/14851445048796393664noreply@blogger.com1