thefrozencoderProgramming and Technology bloghttp://thefrozencoder.ca/
http://www.rssboard.org/rss-specificationBlogEngine.NET 3.3.5.0en-CAhttp://thefrozencoder.ca/opml.axdhttp://www.dotnetblogengine.net/syndication.axdWilliam Highfieldthefrozencoder0.0000000.000000Hyper-V - "Video Remoting Was Disconnected" Error<p>Started to get the error "Video Remoting Was Disconnected" when connecting to a Hyper-V VM using the Admin Console on a local machine (Connecting to the VM via RDP worked fine). All of the more relevant fixes talk about changing the settings on the NIC card which seemed a bit far fetched however I tried them all and none work.</p>
<p>First off my config.</p>
<ul>
<li>Windows 10 device connected to an AD domain</li>
<li>My domain login account has domain admin privileges</li>
<li>My domain login account is part of the local computers Builtin Administrators group</li>
</ul>
<p>The problem eventually was solved by resetting the C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys folder permissions using the following commands</p>
<p><strong>md c:\temp</strong></p>
<p><strong>icacls C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys /t /c &gt; c:\temp\BeforeScript_permissions.txt</strong></p>
<p><strong>takeown /f "C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys" /a /r</strong></p>
<p><strong>icacls C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys /t /c /grant "NT AUTHORITY\System:(F)"</strong></p>
<p><strong>icacls C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys /t /c /grant "NT AUTHORITY\NETWORK SERVICE:(R)"</strong></p>
<p><strong>icacls C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys /t /c /grant "BUILTIN\Administrators:(F)"</strong></p>
<p><strong>icacls C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys /t /c &gt; c:\temp\AfterScript_permissions.txt</strong></p>
<p><strong>Restart-Service TermService -Force</strong></p>
<p>I also rebooted the machine just in case.</p>
<p>I think that something must have been weird-ed out when I joined the computer to the domain / renamed it or something along those lines.</p>
<p>This is not a definitive way to solve this problem as it was a last attempt to fix the issue when all other suggestions failed. You have been warned! lol</p>http://thefrozencoder.ca/post/2019/03/13/hyper-v-video-remoting-was-disconnected-error
http://thefrozencoder.ca/post/2019/03/13/hyper-v-video-remoting-was-disconnected-error#commenthttp://thefrozencoder.ca/post.aspx?id=73999512-1422-451f-8460-fb70d4bd4d52Wed, 13 Mar 2019 03:49:00 -0700ArticlesGeneralthefrozencoderhttp://thefrozencoder.ca/pingback.axdhttp://thefrozencoder.ca/post.aspx?id=73999512-1422-451f-8460-fb70d4bd4d520http://thefrozencoder.ca/trackback.axd?id=73999512-1422-451f-8460-fb70d4bd4d52http://thefrozencoder.ca/post/2019/03/13/hyper-v-video-remoting-was-disconnected-error#commenthttp://thefrozencoder.ca/syndication.axd?post=73999512-1422-451f-8460-fb70d4bd4d52Update to Narayana Vyas Kondreddi's generate insert script for SQL Server 2012<p>If you are like me you like re-using tools that you find extremely simple and easy to use. That is the case with Narayana Vyas Kondreddi&rsquo;s <a href="http://vyaskn.tripod.com/code/generate_inserts.txt" target="_blank">sp_generate_inserts</a> script for SQL Server 2000, 2005, (works with 2008 yet not documented). So when I installed SQL Server 2012 developer my first item was to re-create all of the system stored procs I have in my toolbox.</p>
<p>Unfortunately running the script from the above&nbsp;link will generate an error because the code references a system stored procedure that no longer exists in SQL Server 2012 <strong>master.dbo.sp_MS_upd_sysobj_category</strong>.&nbsp; This stored procedure toggles the system mode feature where any object created while the mode is enabled is flagged as a system object.&nbsp; Since the undocumented sproc does not exist the script will be created but it will not work properly.</p>
<p>However there is a small update that can be done to the original script to fix the issue.</p>
<p>You need to remove the following lines</p>
<p><strong>--Turn system object marking on</strong><br /><strong>EXEC master.dbo.sp_MS_upd_sysobj_category 1</strong><br /><strong>GO</strong></p>
<p>And replace the following lines</p>
<p><strong>--Turn system object marking off</strong><br /><strong>EXEC master.dbo.sp_MS_upd_sysobj_category 2</strong><br /><strong>GO</strong></p>
<p>With</p>
<p><strong>EXEC sys.sp_MS_marksystemobject sp_generate_inserts</strong><br /><strong>GO</strong></p>
<p>The script should ruin without any errors and work as it did in the previous versions.</p>
<p>I have emailed the owner of the script so hopefully he will update the script for 2012.</p>http://thefrozencoder.ca/post/2012/10/14/Update-to-Narayana-Vyas-Kondreddis-generate-insert-script-for-SQL-Server-2012
http://thefrozencoder.ca/post/2012/10/14/Update-to-Narayana-Vyas-Kondreddis-generate-insert-script-for-SQL-Server-2012#commenthttp://thefrozencoder.ca/post.aspx?id=3b43fcfe-266d-4ece-9c98-cf0b6017542aSun, 14 Oct 2012 05:01:00 -0700Developer Toolsthefrozencoderhttp://thefrozencoder.ca/pingback.axdhttp://thefrozencoder.ca/post.aspx?id=3b43fcfe-266d-4ece-9c98-cf0b6017542a0http://thefrozencoder.ca/trackback.axd?id=3b43fcfe-266d-4ece-9c98-cf0b6017542ahttp://thefrozencoder.ca/post/2012/10/14/Update-to-Narayana-Vyas-Kondreddis-generate-insert-script-for-SQL-Server-2012#commenthttp://thefrozencoder.ca/syndication.axd?post=3b43fcfe-266d-4ece-9c98-cf0b6017542aSome fun at the Winnipeg Code Camp 2012<p>Overall the <a title="Winnipeg Code Camp" href="http://www.winnipegcodecamp.com/" target="_blank">Winnipeg Code Camp</a> 2012&nbsp;did not disappoint, lots of interesting sessions to be found and even more interesting people.</p>
<p>One cool item was: Sam - the Twitter Aware, Arduino Powered, Traffic Light.&nbsp; Tyler &amp; Jay talk about Sam: <a href="http://www.youtube.com/watch?v=Cj5Jdfo00xI">http://www.youtube.com/watch?v=Cj5Jdfo00xI</a></p>
<p>These were the following sessions I took in, each of them offered something different and were quite enjoyable.</p>
<ul>
<li>ASP.NET MVC vs. Ruby on Rails SMACKDOWN - ROUND 2! (Part 1) (Marc Jeanson &amp; James Chambers)</li>
<li>ASP.NET MVC vs. Ruby on Rails SMACKDOWN - ROUND 2! (Part 2) (Marc Jeanson &amp; James Chambers)</li>
<li>Git 101: Source Control for the Future (David Alpert)</li>
<li>Software Craftsmanship Panel Discussion (David Alpert, Amir Barylko, James Chambers, and others!)</li>
<li>Illuminated Integration with Team City and Arduino (Tyler Dueck &amp; Jay Smith)</li>
</ul>
<p>P.S. the winner of the smack down was RoR by a significant margin.&nbsp; Both sessions and presenters were very informative and dove into the how each framework handles certain features and "how do you do this" in each framework.</p>
<p>Just want to give a big kudos to the <a title="Winnipeg Code Camp - Organizers" href="http://www.winnipegcodecamp.com/about" target="_blank">organizers</a> and&nbsp;<a title="Winnipeg Code Camp - Speakers" href="http://www.winnipegcodecamp.com/speakers" target="_blank">speakers</a> for putting on another successful code camp as well the folks over at <a title="SkullSpace.ca - Winnipeg's Hackerspace" href="http://skullspace.ca/" target="_blank">Skullspace</a> for hooking up free Wi-Fi for everyone in attendance.</p>http://thefrozencoder.ca/post/2012/02/26/Some-fun-at-the-Winnipeg-Code-Camp-2012
http://thefrozencoder.ca/post/2012/02/26/Some-fun-at-the-Winnipeg-Code-Camp-2012#commenthttp://thefrozencoder.ca/post.aspx?id=129c923d-cded-46b2-8ae3-29bc8fd078b6Sat, 25 Feb 2012 21:54:00 -0700Code DevelopmentIT - Softwarethefrozencoderhttp://thefrozencoder.ca/pingback.axdhttp://thefrozencoder.ca/post.aspx?id=129c923d-cded-46b2-8ae3-29bc8fd078b61http://thefrozencoder.ca/trackback.axd?id=129c923d-cded-46b2-8ae3-29bc8fd078b6http://thefrozencoder.ca/post/2012/02/26/Some-fun-at-the-Winnipeg-Code-Camp-2012#commenthttp://thefrozencoder.ca/syndication.axd?post=129c923d-cded-46b2-8ae3-29bc8fd078b6What I have been up to?<p>Just an update on what I have been up to since my last post. For starters I have been putting in some time helping out with the open source project <a href="http://www.bugnetproject.com/">http://www.bugnetproject.com/</a>. For the most part I have been doing slot of refactoring and general cleanup of the code base. I have also have been doing some UI standardization to make the UI more consistent across the different sections of the site.</p>
<p>From the site:</p>
<blockquote>
<p>BugNET is an open source issue tracking project built using C# and the <a href="http://asp.net/" target="_blank"><span style="color: #3366cc; font-family: Arial; font-size: 10pt; background-color: white;">ASP.NET</span></a> platform. The main goals are to keep the codebase simple, well documented, easy to deploy and scalable.</p>
</blockquote>
<p><br />It has been interesting helping out on an open source project along with the other developers and I have enjoyed working on it so far. I got started working on it because the company I work for <a href="http://core49.com">http://core49.com</a> needed a bug tracking system that would us to track bugs/issues as well we wanted clients to be able to enter issues as well. The first thing I did for the project was update the email template engine to use Xml/Xslt to allow for an easier way to generate some of the issue emails that get sent out.</p>
<p>I look forward to doing more work on the project in the New Year as there are some cool ideas on the drawing board for making it even better.</p>http://thefrozencoder.ca/post/2012/01/07/What-I-have-been-up-to
http://thefrozencoder.ca/post/2012/01/07/What-I-have-been-up-to#commenthttp://thefrozencoder.ca/post.aspx?id=00ce0ba6-d6b6-4c4c-9c64-04f0cb655c89Sat, 7 Jan 2012 02:00:00 -0700Code Developmentthefrozencoderhttp://thefrozencoder.ca/pingback.axdhttp://thefrozencoder.ca/post.aspx?id=00ce0ba6-d6b6-4c4c-9c64-04f0cb655c891http://thefrozencoder.ca/trackback.axd?id=00ce0ba6-d6b6-4c4c-9c64-04f0cb655c89http://thefrozencoder.ca/post/2012/01/07/What-I-have-been-up-to#commenthttp://thefrozencoder.ca/syndication.axd?post=00ce0ba6-d6b6-4c4c-9c64-04f0cb655c89Type 'ContosoUniversity.DAL.Department' could not be found<p>So I was going through the tutorial Handling Concurrency with the Entity Framework in an ASP.NET MVC Application when I encountered this error on step 7 of 10.</p>
<p>Type 'ContosoUniversity.DAL.Department' could not be found. Make sure that the required schemas are loaded and that the namespaces are imported correctly. Near type name, line 1, column 132.</p>
<p>The error is thrown on the following line:</p>
<pre class="auto-links:false;toolbar:false" contenteditable="false">var databaseValues = (Department)entry.GetDatabaseValues().ToObject();
</pre>
<p>This error is due to a bug in EF 4.1 where you separate the DAL and Model Entities out into different namespaces and is referenced here EF4.1 CodeFirst - entry.GetDatabaseValues() throw EntitySqlException.</p>
<p>To fix this issue I came up with this workaround:</p>
<p>Replace the lines:</p>
<pre contenteditable="false">var databaseValues = (Department)entry.GetDatabaseValues().ToObject();
var clientValues = (Department)entry.Entity;</pre>
<p>with the following lines:</p>
<pre contenteditable="false">var clientValues = (Department)entry.CurrentValues.Clone().ToObject();
entry.Reload();
var databaseValues = (Department)entry.CurrentValues.ToObject();</pre>
<p>It seems to work ok for simple concurrency checks and it allows you to continue on with the tutorial.</p>http://thefrozencoder.ca/post/2011/09/11/Type-ContosoUniversity-DAL-Department-could-not-be-found
http://thefrozencoder.ca/post/2011/09/11/Type-ContosoUniversity-DAL-Department-could-not-be-found#commenthttp://thefrozencoder.ca/post.aspx?id=9395d791-a2db-47d7-accb-956b9f48128fSun, 11 Sep 2011 17:00:00 -0700Knowledgebasethefrozencoderhttp://thefrozencoder.ca/pingback.axdhttp://thefrozencoder.ca/post.aspx?id=9395d791-a2db-47d7-accb-956b9f48128f3http://thefrozencoder.ca/trackback.axd?id=9395d791-a2db-47d7-accb-956b9f48128fhttp://thefrozencoder.ca/post/2011/09/11/Type-ContosoUniversity-DAL-Department-could-not-be-found#commenthttp://thefrozencoder.ca/syndication.axd?post=9395d791-a2db-47d7-accb-956b9f48128fConverting a DataTable to a Html table<p>Introduction</p>
<p>This post is another common question I see on the ASP.NET forums "How to convert a DataTable to a Html table".&nbsp; The code uses simple looping through the DataTable&rsquo;s columns and rows/columns to pull the column names and the row data out.&nbsp; I use the HtmlTable, HtmlTableRow and HtmlTableCell objects to actually build the table on the fly.&nbsp; I find this much easier than using a StringBuilder to create the Html.</p>
<p>The code samples in this post can be downloaded using the link at the bottom and were created using Visual Studio 2010.&nbsp; There are samples for both C# and Visual Basic.NET in the download file as well.</p>
<p><a href="http://thefrozencoder.ca/file.axd?file=2010%2f11%2fDataTableToHtml.zip">DataTableToHtml.zip (24 kb)</a></p>http://thefrozencoder.ca/post/2010/11/20/Converting-a-DataTable-to-a-Html-table
http://thefrozencoder.ca/post/2010/11/20/Converting-a-DataTable-to-a-Html-table#commenthttp://thefrozencoder.ca/post.aspx?id=ee8c9757-1c31-4335-a925-f4a0ec19d343Sat, 20 Nov 2010 04:58:00 -0700ArticlesCode Developmentthefrozencoderhttp://thefrozencoder.ca/pingback.axdhttp://thefrozencoder.ca/post.aspx?id=ee8c9757-1c31-4335-a925-f4a0ec19d3430http://thefrozencoder.ca/trackback.axd?id=ee8c9757-1c31-4335-a925-f4a0ec19d343http://thefrozencoder.ca/post/2010/11/20/Converting-a-DataTable-to-a-Html-table#commenthttp://thefrozencoder.ca/syndication.axd?post=ee8c9757-1c31-4335-a925-f4a0ec19d343Summary totals in a GridView<p><strong>Introduction</strong></p>
<p>This post is in response to the common request on the ASP.NET forums for adding summary totals in a GridView control.&nbsp; The idea is to use the FooterTemplate of each column in the GridView that has some kind of value to place the summary of the column.&nbsp; The sample also goes on to show how to use the RowDataBound event to set the actual totals as well to add a Total Price column that takes a quantity field and a price field to display the total for each line.</p>
<p>The code samples in this post can be downloaded using the link at the bottom and were created using Visual Studio 2010.&nbsp; There are samples for both C# and Visual Basic.NET in the download file as well.</p>
<p><strong>Implementation</strong></p>
<p><strong>Default.aspx Page</strong></p>
<p><img src="http://thefrozencoder.ca/image.axd?picture=2010%2f6%2ftotals_grid_sample.jpg" alt="" /></p>
<p>What we want on the grid is simple enough, display a line by line total as well a summary of the Qty and Total Price fields.&nbsp; Below are the columns that make up the grid view.&nbsp; For the columns that come out of the database we would simply use BoundField columns.&nbsp; For our calculated columns we want to use a TemplateField so we can add asp.net controls to the columns so we can inject our own data.&nbsp; I tend to use the Literal control as it renders just the contents of the Text property vs the Label control that renders a SPAN html tag.&nbsp; For the columns that will contain a summary total we use the FooterTemplate to place Literal controls so we can write the summary data out.</p>
<pre class="brush:xml;auto-links:false;gutter:false;toolbar:false" contenteditable="false"> &lt;Columns&gt;
&lt;asp:BoundField DataField="Description" HeaderText="Description"&gt;
&lt;HeaderStyle HorizontalAlign="Left" /&gt;
&lt;ItemStyle HorizontalAlign="Left" /&gt;
&lt;/asp:BoundField&gt;
&lt;asp:BoundField DataField="Price" HeaderText="Price" DataFormatString="{0:c}"&gt;
&lt;HeaderStyle HorizontalAlign="Right" Width="100" /&gt;
&lt;ItemStyle HorizontalAlign="Right" Width="100" /&gt;
&lt;/asp:BoundField&gt;
&lt;asp:TemplateField HeaderText="Qty"&gt;
&lt;ItemTemplate&gt;
&lt;asp:Literal ID="litQty" runat="server" Text="0" /&gt;
&lt;/ItemTemplate&gt;
&lt;FooterTemplate&gt;
&lt;asp:Literal ID="litSumQty" runat="server" Text="0" /&gt;
&lt;/FooterTemplate&gt;
&lt;HeaderStyle HorizontalAlign="Right" Width="100" /&gt;
&lt;ItemStyle HorizontalAlign="Right" Width="100" /&gt;
&lt;FooterStyle HorizontalAlign="Right" Width="100" /&gt;
&lt;/asp:TemplateField&gt;
&lt;asp:TemplateField HeaderText="Total Price"&gt;
&lt;ItemTemplate&gt;
&lt;asp:Literal ID="litTotalPrice" runat="server" Text="0" /&gt;
&lt;/ItemTemplate&gt;
&lt;FooterTemplate&gt;
&lt;asp:Literal ID="litSumTotalPrice" runat="server" Text="0" /&gt;
&lt;/FooterTemplate&gt;
&lt;HeaderStyle HorizontalAlign="Right" Width="100" /&gt;
&lt;ItemStyle HorizontalAlign="Right" Width="100" /&gt;
&lt;FooterStyle HorizontalAlign="Right" Width="100" /&gt;
&lt;/asp:TemplateField&gt;
&lt;/Columns&gt;</pre>
<p><strong>Default.aspx.cs Code Behind </strong></p>
<p>To inject our computed data we use the RowDataBound event on the grid.&nbsp; This event is fired for every row when the data is bound to the row and allows us access to the controls and the data at the same time.&nbsp; We first check if the current row type is a DataRow (items in the grid) and then we grab an instance of the actual data that makes up the row.&nbsp; This will be different if you are using a generic list of your objects, you would cast the DataItem as that object.&nbsp; Then we get a reference to the data from the DataRow and perform our calculations, then we get an instance of the Literal controls in the row, check if they are null or not (null would mean we did not find them) and set the Text value.</p>
<pre class="brush:csharp;auto-links:false;gutter:false;toolbar:false" contenteditable="false"> protected void GridView1_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView dr = (DataRowView)e.Row.DataItem;
int qty = (int)dr["Qty"];
decimal price = (decimal)dr["Price"];
decimal totalPrice = qty * price;
Literal litTotalPrice = (Literal)e.Row.FindControl("litTotalPrice");
Literal litQty = (Literal)e.Row.FindControl("litQty");
if ((litQty != null))
litQty.Text = qty.ToString();
if ((litTotalPrice != null))
litTotalPrice.Text = totalPrice.ToString("c");
}
if (e.Row.RowType == DataControlRowType.Footer)
{
int qty = 0;
decimal price = default(decimal);
GetTableTotals(ref qty, ref price);
Literal litSumTotalPrice = (Literal)e.Row.FindControl("litSumTotalPrice");
Literal litSumQty = (Literal)e.Row.FindControl("litSumQty");
if ((litSumQty != null))
litSumQty.Text = qty.ToString();
if ((litSumTotalPrice != null))
litSumTotalPrice.Text = price.ToString("c");
}
}</pre>
<p>If the RowType is Footer we need to get the summary data from the entire table of data.&nbsp; To do this we use some Linq in the GetTableTotals() method to get a sum of the quantity and calculate the sum of the quantity * price for each data row.</p>
<pre class="brush:csharp;auto-links:false;gutter:false;toolbar:false" contenteditable="false"> public void GetTableTotals(ref int qty, ref decimal price)
{
DataTable dt = (DataTable)GridView1.DataSource;
var rows = dt.AsEnumerable();
qty = rows.Sum(p =&gt; (int)p["Qty"]);
price = (from p in rows select (int)p["Qty"] * (decimal)p["Price"]).Sum();
}</pre>
<p>Code: <a href="http://thefrozencoder.ca/file.axd?file=2010%2f6%2fGridTotalsSample.zip">GridTotalsSample.zip (22.01 kb)</a></p>http://thefrozencoder.ca/post/2010/06/28/Summary-totals-in-a-GridView
http://thefrozencoder.ca/post/2010/06/28/Summary-totals-in-a-GridView#commenthttp://thefrozencoder.ca/post.aspx?id=c6f5a45e-2a3b-4ea3-ac00-30c0d88ec2ceMon, 28 Jun 2010 12:13:00 -0700ArticlesCode Developmentthefrozencoderhttp://thefrozencoder.ca/pingback.axdhttp://thefrozencoder.ca/post.aspx?id=c6f5a45e-2a3b-4ea3-ac00-30c0d88ec2ce0http://thefrozencoder.ca/trackback.axd?id=c6f5a45e-2a3b-4ea3-ac00-30c0d88ec2cehttp://thefrozencoder.ca/post/2010/06/28/Summary-totals-in-a-GridView#commenthttp://thefrozencoder.ca/syndication.axd?post=c6f5a45e-2a3b-4ea3-ac00-30c0d88ec2ceMove your appSettings out of the web.config file<p><strong>Introduction</strong></p>
<p>This post goes about showing you how you can implement common global settings without using the web.config's appSettings section.&nbsp; The idea is simple and taken from the latest craze of document based databases like <a title="RavenDB home page" href="http://ravendb.net/" target="_blank">RavenDB</a>.&nbsp; Why not create an object for your settings serialize it to a standard format and then just persist it to a file.&nbsp; Now you probably don&rsquo;t want to go and store passwords and such in the file (unless you encrypt them first) but for the most common settings it&rsquo;s a nice alternative to the web.config appSettings which is pretty limited.&nbsp; Now some people may say why not a database?&nbsp; Well unless you are running under a server farm (and then you probably have a common share between all web servers in the farm) to me a database is a little over-kill for the most part</p>
<p>The code samples in this post can be downloaded using the link at the bottom and were created using Visual Studio 2010.&nbsp; There are samples for both C# and Visual Basic.NET in the download file as well.&nbsp; There is an external dependency (<a title="json.net home page" href="http://james.newtonking.com/projects/json-net.aspx" target="_blank">JSON.NET</a>) that is included in the lib folder it is used to serialize and de-serialize the SettingsStore object.</p>
<p><strong>Implementation</strong></p>
<p><strong>Default.aspx page UI</strong></p>
<p><img src="http://thefrozencoder.ca/image.axd?picture=2010%2f6%2fSettings_Form.jpg" alt="" /></p>
<p>The UI is simple enough, just have a way to allow users to update the settings from the setting class.</p>
<p><strong>SettingsLib Code</strong></p>
<p>The SettingsLib class implements the&nbsp;getting and the persisting of the&nbsp;actual settings.&nbsp; By default the site_settings.config file is stored in a folder called app_data, this can be changed to anything but just remember the windows account that your website runs under must have write access to this folder for the settings to be persisted.</p>
<pre class="brush:csharp;auto-links:false;gutter:false;toolbar:false" contenteditable="false"> public static class SettingsLib
{
public const string SETTINGS_FILE_NAME = "site_settings.config";
///
/// Gets the current Settings object from the settings store
///
/// Settings object
public static SettingsStore GetSettings()
{
return JsonConvert.DeserializeObject(ReadSettingsFile());
}
///
/// Saves the settings to the settings store
///
///The current Settings object
///
public static bool SaveSettings(SettingsStore settings)
{
return WriteSettingsFile(JsonConvert.SerializeObject(settings));
}
///
/// Reads the json data from the settings file
///
/// json string from the file
private static string ReadSettingsFile()
{
string settings = "{ }";
string path = GetPath();
try
{
if (File.Exists(path))
settings = File.ReadAllText(path);
}
catch (Exception) { }
return settings;
}
///
/// Writes the json string to the settings file
///
///The json string that represents the Settings object
/// True | False if the write was successful
static bool WriteSettingsFile(string json)
{
string path = GetPath();
try
{
File.WriteAllText(path, json);
return true;
}
catch (Exception) { }
return false;
}
///
/// Returns the full file path to the settings file
///
///
static string GetPath()
{
string path = System.Web.HttpContext.Current.Server.MapPath("~\\app_data");
if (!path.EndsWith("\\")) path += "\\";
path = string.Concat(path, "\\", SETTINGS_FILE_NAME);
return path;
}
}</pre>
<p><strong>SettingsStore Class</strong></p>
<p>The SettingsStore class is just a simple class that implements your settings as an object using properties.&nbsp; JSON.NET will serialze most primative .net types as well collections too which makes it more flexable than using the web.config file.</p>
<pre class="brush:csharp;auto-links:false;gutter:false;toolbar:false" contenteditable="false"> ///
/// Class to hold all of your settings
///
public class SettingsStore
{
public string UploadFolder { get; set; }
public string EmailErrorsTo { get; set; }
public string EmailServerHostname { get; set; }
}</pre>
<p>Code <a href="http://thefrozencoder.ca/file.axd?file=2010%2f6%2fSettingsStoreSample.zip">SettingsStoreSample.zip (176.40 kb)</a></p>http://thefrozencoder.ca/post/2010/06/20/Move-your-appSettings-out-of-the-web-config-file
http://thefrozencoder.ca/post/2010/06/20/Move-your-appSettings-out-of-the-web-config-file#commenthttp://thefrozencoder.ca/post.aspx?id=fa327fc9-2d53-46d8-9d38-6cd9938f5a34Sun, 20 Jun 2010 07:35:00 -0700ArticlesCode Developmentthefrozencoderhttp://thefrozencoder.ca/pingback.axdhttp://thefrozencoder.ca/post.aspx?id=fa327fc9-2d53-46d8-9d38-6cd9938f5a340http://thefrozencoder.ca/trackback.axd?id=fa327fc9-2d53-46d8-9d38-6cd9938f5a34http://thefrozencoder.ca/post/2010/06/20/Move-your-appSettings-out-of-the-web-config-file#commenthttp://thefrozencoder.ca/syndication.axd?post=fa327fc9-2d53-46d8-9d38-6cd9938f5a34Installing a 3rd party expansion bay in my laptop<p>I recently purchased a 3rd party expansion bay caddy (replacement part AK868AA) for my HP EliteBook 8350p laptop so I could have two HD's as well&nbsp;upgrade my original HD to a 7200rpm larger drive.&nbsp; I would end up installing the new HD as my primary and use the original as a secondary "data" drive for music, videos, VM's and other large files.</p>
<p>I purchased the expansion bay caddy from a 3rd party company (<a href="http://newmodeus.com/" target="_blank">NewmodeUS.com</a>) off of their eBay store and had no problems with the transaction.&nbsp; Upon receiving the caddy I also noticed that there were no instructions but really how hard can it be right?</p>
<p>Actually I did have one issue when I went to install the caddy into the laptop, it involved a little extra work so I found.&nbsp; Below is the process I used to install the HD into the caddy and into my laptop.&nbsp; It does not explain how to remove the original HD and replace it with the new HD.&nbsp; HP has manuals for that on their site.</p>
<p>The following steps are done at your own risk and I cannot take any responsibility if any damaged is caused by you or to your laptop.&nbsp; To make things easier my laptop was sitting with the battery compartment facing up or away from me.</p>
<p><strong>Step 1:</strong> Remove the battery from the laptop.</p>
<p><strong>Step 2:</strong> Remove the original expansion bay caddy (the one that holds the DVD player) by unscrewing the screw that fastens the expansion bay caddy to the laptop chassis and using a flat head screw driver push on the silver tab in the picture to the left to pop the caddy out far enough so you can remove it (see image below as a reference).</p>
<p><a href="http://thefrozencoder.ca/image.axd?picture=2009%2f10%2flaptop_cover.JPG" target="_blank"><img style="border: 0px;" title="Click to open larger image" src="http://thefrozencoder.ca/image.axd?picture=2009%2f10%2flaptop_cover.JPG" alt="" width="548" height="411" /></a></p>
<p><strong></strong></p>
<p><strong>Step 3:</strong> Prep your new expansion bay caddy by installing your new hard drive, make sure to screw the HD to the caddy and transfer the fastening mounting bracket from the existing caddy to your new caddy using the supplied screws</p>
<p><a href="http://thefrozencoder.ca/image.axd?picture=2009%2f10%2fprep_new_caddy.JPG" target="_blank"><img style="border: 0px;" title="Click to open larger image" src="http://thefrozencoder.ca/image.axd?picture=2009%2f10%2fprep_new_caddy.JPG" alt="" width="547" height="411" /></a></p>
<p><strong>Step 4:</strong> Use 3 screws from the supplied screws and fasten your new expansion bay cover, there are 3 screw holes on the bottom of the expansion bay caddy so that the case stays closed.</p>
<p><strong>Step 5:</strong> Slide the expansion bay caddy into the expansion bay is flush with the laptop case or until you feel it cannot go in anymore.&nbsp; The silver tab you pried to release the caddy should be visible in the slot, if you do not see the little silver tab then you may have to follow steps 6 - 9.</p>
<p><strong>Step 6:</strong> Remove the memory cover by unscrewing two screws pictured below and lift and slide the cover to the right.</p>
<p><img style="border: 0px;" title="Click to open larger image" src="http://thefrozencoder.ca/image.axd?picture=2009%2f10%2flaptop_cover.JPG" alt="" width="548" height="411" /></p>
<p><strong>Step 7:</strong> If you have memory in the bay closest to the expansion bay caddy (left memory bay) you might want to remove it by prying the two sliver retainers&nbsp; on each end of the RAM module away from the center of the RAM module, the RAM module will pop up at an angle so you can remove it.</p>
<p><a href="http://thefrozencoder.ca/image.axd?picture=2009%2f10%2fremove_memory.JPG" target="_blank"><img style="border: 0px;" title="Click to open larger image" src="http://thefrozencoder.ca/image.axd?picture=2009%2f10%2fremove_memory.JPG" alt="" width="548" height="411" /></a></p>
<p><strong>Step 8:</strong> If you look at the picture below you will see the grey connector (circled in red), this is the expansion bays SATA connector (do this by looking inside of the laptop at an angle toward the expansion bay slot).</p>
<p><a href="http://thefrozencoder.ca/image.axd?picture=2009%2f10%2fsata_connector.JPG" target="_blank"><img style="border: 0px;" title="Click to open larger image" src="http://thefrozencoder.ca/image.axd?picture=2009%2f10%2fsata_connector.JPG" alt="" width="548" height="411" /></a></p>
<p><strong>Step 9:</strong> Slide the expansion bay caddy into the slot until it stops.&nbsp; Slide the flat head screw driver&nbsp;under the chassis so that it rests on the SATA connector then lift up on the screwdriver using the chassis as a leverage point so you can carefully push the SATA connector downwards slightly.&nbsp; At the same time push the expansion bay caddy in.&nbsp; The caddy should slide the rest of the way in (it did in my case but your mileage may vary based on the laptop model).&nbsp; You now should see the little silver tab you had to pry to get the DVD player out.</p>
<p><strong>Step 10:</strong> Once this is done screw the fastening screw down and put back all the covers/memory/screws you removed.</p>
<p>Turn on your laptop and hopefully you should see your new drive.</p>
<p><em><strong>Note:</strong> if you were like me and you made the new HD your primary drive and used the original HD as the drive to go in the expansion bay you will need to go into the BIOS and make sure the expansion bay device is NOT the first device to boot from in the list.&nbsp; If you don't well your old HD will boot.</em></p>
<p><em><strong>Note:</strong> Because the second drive is not buried in the laptop you will notice the noise when the second drive is being accessed, it is no way louder than the DVD drive when being accessed but you will notice it if you are copying large or a large amount of files to and from it.</em></p>http://thefrozencoder.ca/post/2009/10/11/Installing-a-3rd-party-expansion-bay-in-my-laptop
http://thefrozencoder.ca/post/2009/10/11/Installing-a-3rd-party-expansion-bay-in-my-laptop#commenthttp://thefrozencoder.ca/post.aspx?id=2ce79ed8-1ccb-4214-8f97-afa13c0a947bSun, 11 Oct 2009 04:56:00 -0700Hardwarethefrozencoderhttp://thefrozencoder.ca/pingback.axdhttp://thefrozencoder.ca/post.aspx?id=2ce79ed8-1ccb-4214-8f97-afa13c0a947b0http://thefrozencoder.ca/trackback.axd?id=2ce79ed8-1ccb-4214-8f97-afa13c0a947bhttp://thefrozencoder.ca/post/2009/10/11/Installing-a-3rd-party-expansion-bay-in-my-laptop#commenthttp://thefrozencoder.ca/syndication.axd?post=2ce79ed8-1ccb-4214-8f97-afa13c0a947bCode highlighting integration for BlogEngine.NET 1.5.x<p>I decided to integrate some code highlighting into my blog rather than taking screen captures of my code and posting those into the blog.&nbsp; As I found this requires integrating a code inserting plug-in for TinyMCE 3.x to insert code into the editor and format it properly and syntax highlighting extension for the actual posted code.&nbsp; The two I chose were:</p>
<p>David Pokluda&rsquo;s Windows Live Writer Source Code Plug-in found <a title="Windows Live Writer Source Code plug-in" href="http://blog.pokluda.com/post/Windows-Live-Writer-Source-Code-plug-in.aspx" target="_blank">here</a>. I simply took the BlogEngine.NET bits from the download and followed the instructions to install it.&nbsp; This download also included Alex Gorbatchev&rsquo;s syntax highlighter - v. 2.0.296 &ndash; found <a title="Syntax Highlighter Download" href="http://alexgorbatchev.com/wiki/SyntaxHighlighter" target="_blank">here</a>.&nbsp; The idea is there is a BlogEngine.NET extension that writes the SyntaxHighlighter js code to the pages.</p>
<p>And the code inserting plug-in for TinyMCE v3.x I got from Nawaf&rsquo;s Blog found <a title="Syntax Highlighter Plug-in for TinyMCE 3.x" href="http://weblogs.asp.net/nawaf/archive/2008/04/10/syntaxhighlighter-plug-in-for-tinymce-3-x-wysiwyg-editor.aspx" target="_blank">here</a>.</p>
<p>I had to do some tweaking to get the TinyMCE plug-in to work the way I wanted.&nbsp; By default the plug-in wraps the code in a HTML textarea along with some attributes (settings) in the class attribute.&nbsp; I really don&rsquo;t like that approach (having a textarea in a post and or the TinyMCE editor when editing).&nbsp; So I ended up changing the plug-in code to output a HTML pre tag and mapping some of the settings from the plug-in to the settings of the syntax highlighter code since Alex Gorbatchev&rsquo;s code looks for a pre tag anyway.</p>
<p>The changes I made to the plug-in were in the codehighlighting\js\codehighlighting.js file and these are the changes I made:</p>
<pre class="brush:js;auto-links:false;gutter:false;toolbar:false" contenteditable="false">function Save_Button_onclick() {
var lang = document.getElementById("ProgrammingLangauges").value;
var code = WrapCode(lang);
code = code + document.getElementById("CodeArea").value;
code = code + "&lt;/pre&gt;";
if (document.getElementById("CodeArea").value == '')
{
tinyMCEPopup.close();
return false;
}
tinyMCEPopup.execCommand('mceInsertContent', false, code);
tinyMCEPopup.close();
}
function WrapCode(lang) {
var options = "auto-links: true; first-line: 1; light: false; ruler: false; smart-tabs: true; tab-size: 4;brush: " + lang + ";";
var html = "";
if (lang == 'js' || lang == 'jscript' || lang == 'javascript')
options = options + "html-script: true;";
else
options = options + "html-script: false;";
if (document.getElementById("nogutter").checked == true)
options = options + "gutter: false;";
if (document.getElementById("collapse").checked == true)
options = options + "collapse: true;";
if (document.getElementById("nocontrols").checked == true)
options = options + "toolbar: false;";
html = "&lt;pre class='" + options + "'&gt;";
return html;
}
function Cancel_Button_onclick() {
tinyMCEPopup.close();
return false;
}</pre>
<p>As you can see most of the changes were to the WrapCode function (if you compare the original to my version side by side).&nbsp; Other than that nothing really needed to be done to the syntax highlighter code or the BlogEngine.NET extension.</p>
<p>Instructions for installation can be found on each respective website.</p>
<p><strong>Note:</strong> <em>There is a bit of weirdness with the TinyMCE plug-in where if there is HTML tags in your code you will need to manually encode them, I am not sure what is going on but I find it's not that much of a big deal.</em></p>
<p>Enjoy</p>http://thefrozencoder.ca/post/2009/08/16/Code-highlighting-integration-for-BlogEngineNET-1-5x
http://thefrozencoder.ca/post/2009/08/16/Code-highlighting-integration-for-BlogEngineNET-1-5x#commenthttp://thefrozencoder.ca/post.aspx?id=91db9751-048d-4d43-ad81-ec6f0dc6b630Sun, 16 Aug 2009 09:32:00 -0700Web Sitethefrozencoderhttp://thefrozencoder.ca/pingback.axdhttp://thefrozencoder.ca/post.aspx?id=91db9751-048d-4d43-ad81-ec6f0dc6b6300http://thefrozencoder.ca/trackback.axd?id=91db9751-048d-4d43-ad81-ec6f0dc6b630http://thefrozencoder.ca/post/2009/08/16/Code-highlighting-integration-for-BlogEngineNET-1-5x#commenthttp://thefrozencoder.ca/syndication.axd?post=91db9751-048d-4d43-ad81-ec6f0dc6b630