<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tech Blog is Tech &#187; Windows</title>
	<atom:link href="http://www.techblogistech.com/category/windows/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.techblogistech.com</link>
	<description>Exploring technology in the modern world</description>
	<lastBuildDate>Sat, 04 May 2013 14:10:47 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>NHibernate AutoMapping Persister Error</title>
		<link>http://www.techblogistech.com/2013/03/nhibernate-automapping-persister-error/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=nhibernate-automapping-persister-error</link>
		<comments>http://www.techblogistech.com/2013/03/nhibernate-automapping-persister-error/#comments</comments>
		<pubDate>Tue, 26 Mar 2013 23:00:41 +0000</pubDate>
		<dc:creator>sean</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[.net framework 4]]></category>
		<category><![CDATA[automappingconfiguration]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[fluentconfiguration]]></category>
		<category><![CDATA[fluentnhibernate]]></category>
		<category><![CDATA[mappingexception]]></category>
		<category><![CDATA[model]]></category>
		<category><![CDATA[nhibernate]]></category>
		<category><![CDATA[persister]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.techblogistech.com/?p=1022</guid>
		<description><![CDATA[If you&#8217;ve configured FluentNHibernate with automapping, it&#8217;s easy to run into a persister error like the one below. NHibernate.MappingException: No &#8230; <span class="more-link"><a href="http://www.techblogistech.com/2013/03/nhibernate-automapping-persister-error/">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.techblogistech.com/wp-content/uploads/2012/03/microsoft.net_.png" rel="shadowbox[sbpost-1022];player=img;"><img class="lazy alignright size-medium wp-image-820" title="microsoft.net" alt="Microsoft .NET" src="http://www.techblogistech.com/wp-content/plugins/jquery-image-lazy-loading/images/grey.gif" data-original="http://www.techblogistech.com/wp-content/uploads/2012/03/microsoft.net_-300x192.png" width="100" height="64" /><noscript><img class="alignright size-medium wp-image-820" title="microsoft.net" alt="Microsoft .NET" src="http://www.techblogistech.com/wp-content/uploads/2012/03/microsoft.net_-300x192.png" width="100" height="64" /></noscript></a>If you&#8217;ve configured FluentNHibernate with automapping, it&#8217;s easy to run into a persister error like the one below.</p>
<pre>
NHibernate.MappingException: No persister for:
XYZ.ProductName.Model.Customer
</pre>
<p>But this was working last time I compiled and I haven&#8217;t been writing database code. What could I have done?</p>
<h2>The Problem</h2>
<p>NHibernate cannot find your model. Did you move it? Maybe you were just doing some refactoring and you moved the models to a different namespace?</p>
<h2>Check Your FluentConfiguration</h2>
<p>First you should check your <strong>FluentConfiguration</strong> and make sure you&#8217;ve actually wired up the model that&#8217;s missing.</p>
<pre>
var automappingConfiguration = new MyAutomappingConfiguration();
Fluently.Configure()
                    .Database(SQLiteConfiguration.Standard.ConnectionString(connectionString).ShowSql())
                    .Mappings
                    (
                        m => m.AutoMappings.Add(AutoMap.AssemblyOf&lt;Customer>(automappingConfiguration))
                    )
                    .BuildConfiguration();
</pre>
<p>Yep, there&#8217;s our <strong>Customer</strong>. So why can&#8217;t NHibernate find it?</p>
<h2>Check Your AutomappingConfiguration</h2>
<p>Next you should check your <strong>AutomappingConfiguration</strong> and make sure it&#8217;s pointing to the correct namespace.</p>
<pre>
public class MyAutomappingConfiguration : DefaultAutomappingConfiguration
{
	public override bool ShouldMap(Type type)
	{
		return type.Namespace == "XYZ.ProductName.SomeOtherProject.Models";
	}
}
</pre>
<p>Doh! I moved those models to a new namespace during some refactoring with <a href="http://www.jetbrains.com/resharper/" title="JetBrains: Resharper Homepage" target="_blank">Resharper</a>. I better update the namespace in my <strong>AutomappingConfiguration</strong>.</p>
<p>&#8212;</p>
<p>Hopefully you&#8217;ve managed to help NHibernate find your models now.</p>
<p>Have fun coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techblogistech.com/2013/03/nhibernate-automapping-persister-error/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configuring FluentNHibernate with SQLite in .NET 4</title>
		<link>http://www.techblogistech.com/2013/03/configuring-fluentnhibernate-with-sqlite-in-net-4/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=configuring-fluentnhibernate-with-sqlite-in-net-4</link>
		<comments>http://www.techblogistech.com/2013/03/configuring-fluentnhibernate-with-sqlite-in-net-4/#comments</comments>
		<pubDate>Sun, 24 Mar 2013 23:53:42 +0000</pubDate>
		<dc:creator>sean</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[.net framework 4]]></category>
		<category><![CDATA[assemblybinding]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[fluentnhibernate]]></category>
		<category><![CDATA[nhibernate]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[qualifyassembly]]></category>
		<category><![CDATA[sqlite]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[x64]]></category>
		<category><![CDATA[x86]]></category>

		<guid isPermaLink="false">http://www.techblogistech.com/?p=978</guid>
		<description><![CDATA[Configuring FluentNHibernate with SQLite can be a bit painful, particularly because the SQLite assemblies are built separately for x86 and &#8230; <span class="more-link"><a href="http://www.techblogistech.com/2013/03/configuring-fluentnhibernate-with-sqlite-in-net-4/">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.techblogistech.com/wp-content/uploads/2012/03/microsoft.net_.png" rel="shadowbox[sbpost-978];player=img;"><img class="lazy alignright size-medium wp-image-820" title="microsoft.net" alt="Microsoft .NET" src="http://www.techblogistech.com/wp-content/plugins/jquery-image-lazy-loading/images/grey.gif" data-original="http://www.techblogistech.com/wp-content/uploads/2012/03/microsoft.net_-300x192.png" width="100" height="64" /><noscript><img class="alignright size-medium wp-image-820" title="microsoft.net" alt="Microsoft .NET" src="http://www.techblogistech.com/wp-content/uploads/2012/03/microsoft.net_-300x192.png" width="100" height="64" /></noscript></a>Configuring FluentNHibernate with SQLite can be a bit painful, particularly because the SQLite assemblies are built separately for x86 and x64. On top of that, because NHibernate is loading the SQLite DLL at runtime, the DLL needs to be in a location that NHibernate can find it. When trying to set this up myself, I ran into the following error:</p>
<pre>
An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection,
and InnerException for more details.
</pre>
<p>And the inner exception looked like this:</p>
<pre>
Could not create the driver from NHibernate.Driver.SQLite20Driver, NHibernate, Version=3.3.1.4000, Culture=neutral,
PublicKeyToken=aa95f207798dfdb4.
</pre>
<h2>The Problem</h2>
<p>Typically this error just means NHibernate cannot locate and load the SQLite DLL. This could be because you&#8217;re trying to load the 64-bit DLL under a 32-bit project or vice-versa. I noticed a lot of people were simply configuring their Visual Studio projects for x86 and referencing only the x86 SQLite DLL to solve this problem, but this is unnecessary. Below I&#8217;ll explain how to set this up properly.</p>
<h2>The Solution</h2>
<p>Basically the <strong>System.Data.SQLite</strong> DLL needs to be in the same directory as the NHibernate DLL. Typically, whichever Visual Studio project is set as the startup project (your main application interface) should have a reference to <strong>System.Data.SQLite</strong>. So just add the NuGet package to that project, as well as any test projects that may need access to the database as well.</p>
<h2>The Long-winded Solution</h2>
<p>Or if the above wasn&#8217;t clear enough&#8230;</p>
<h3>Install FluentNHibernate</h3>
<p>Firstly, you need to have FluentNHibernate installed and referenced in your project. For this, I would recommend installing <a href="http://nuget.org/" title="NuGet Homepage" target="_blank">NuGet</a>.</p>
<p>After NuGet is installed, just grab the package using the GUI or run the <strong>Install-Package</strong> command from the NuGet prompt:</p>
<pre class="bash">
PM> Install-Package FluentNHibernate
</pre>
<p>You&#8217;ll reference FluentNHibernate from any project that uses it in the code, just like normal.</p>
<h3>Configure FluentNHibernate</h3>
<p>Make sure you&#8217;re building a valid NHibernate configuration in your code using <strong>Fluently.Configure()</strong> and that you&#8217;re using <strong>FluentNHibernate.Cfg.Db.SQLiteConfiguration</strong>.</p>
<h3>Install SQLite</h3>
<p>Using NuGet, grab the package using the GUI or run the <strong>Install-Package</strong> command from the NuGet prompt:</p>
<pre class="bash">
PM> Install-Package System.Data.SQLite
</pre>
<p>Make sure you&#8217;re installing <strong>System.Data.SQLite</strong> and <strong>NOT</strong> installing System.Data.SQLite.x86 or System.Data.SQLite.x64. The <strong>System.Data.SQLite</strong> package contains both the x86 and x64 versions of the DLL, which is what I would recommend if you want to compile your application for both 32-bit and 64-bit machines.</p>
<h3>Reference SQLite</h3>
<p>Add to reference to <strong>System.Data.SQLite</strong> to your primary application project (e.g. the startup project, the GUI, etc.). Also add a reference to any test projects that use the database, such as your NUnit tests.</p>
<h3>You&#8217;re Done?</h3>
<p>Does it work? If so, congrats! Happy coding!</p>
<h2>It Didn&#8217;t Work</h2>
<p>Ok, so if it didn&#8217;t work, you can try telling .NET which assembly to load.</p>
<h3>Update Your App.config or Web.config</h3>
<p>In your <strong>App.config</strong> or <strong>Web.config</strong> for your main application or any other projects that access the database, add the following:</p>
<pre>
  &lt;runtime>
    &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      &lt;qualifyAssembly partialName="System.Data.SQLite"
          fullName="System.Data.SQLite, Version=1.0.84.0,
          Culture=neutral, PublicKeyToken=db937bc2d44ff139"/>
    &lt;/assemblyBinding>
  &lt;/runtime>
</pre>
<p>The <strong>qualifyAssembly</strong> element specifies the full name of the assembly that should be dynamically loaded when a partial name is used; this should ensure the correct version is loaded at runtime.</p>
<p>Also, if you&#8217;re wondering how I got the PublicKeyToken for the DLL, check out my article on <a href="http://www.techblogistech.com/2013/03/how-to-find-public-key-token/" title="How to find the public key token for a .NET DLL or assembly" target="_blank">finding the public key token for a .NET DLL or assembly</a>.</p>
<h2>Finish Line</h2>
<p>You&#8217;re all done! Now you can use FluentNHibernate and SQLite in both x86 and x64 mode. The correct DLL should be loaded based on your project/compiler settings.</p>
<p>Happy hacking!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techblogistech.com/2013/03/configuring-fluentnhibernate-with-sqlite-in-net-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to find the public key token for a .NET DLL or assembly</title>
		<link>http://www.techblogistech.com/2013/03/how-to-find-public-key-token/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-find-public-key-token</link>
		<comments>http://www.techblogistech.com/2013/03/how-to-find-public-key-token/#comments</comments>
		<pubDate>Sun, 24 Mar 2013 23:23:16 +0000</pubDate>
		<dc:creator>sean</dc:creator>
				<category><![CDATA[Administration]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[.net framework 4]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[dll]]></category>
		<category><![CDATA[gacutil]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[public key token]]></category>
		<category><![CDATA[sn]]></category>
		<category><![CDATA[sn.exe]]></category>
		<category><![CDATA[strongly named assembly]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.techblogistech.com/?p=973</guid>
		<description><![CDATA[When using .NET, sometimes you need the public key token for a strongly named assembly. Below I&#8217;ll explain how to &#8230; <span class="more-link"><a href="http://www.techblogistech.com/2013/03/how-to-find-public-key-token/">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.techblogistech.com/wp-content/uploads/2012/03/microsoft.net_.png" rel="shadowbox[sbpost-973];player=img;"><img class="lazy alignright size-medium wp-image-820" title="microsoft.net" alt="Microsoft .NET" src="http://www.techblogistech.com/wp-content/plugins/jquery-image-lazy-loading/images/grey.gif" data-original="http://www.techblogistech.com/wp-content/uploads/2012/03/microsoft.net_-300x192.png" width="100" height="64" /><noscript><img class="alignright size-medium wp-image-820" title="microsoft.net" alt="Microsoft .NET" src="http://www.techblogistech.com/wp-content/uploads/2012/03/microsoft.net_-300x192.png" width="100" height="64" /></noscript></a>When using .NET, sometimes you need the public key token for a strongly named assembly. Below I&#8217;ll explain how to glean that information using <strong>sn</strong> or <strong>gacutil</strong>.</p>
<h2>Where are these utilities?</h2>
<p>The two utilities you can use to get public key tokens are <strong>sn</strong> and <strong>gacutil</strong>. You can find either of them in the <strong>Visual Studio Command Prompt</strong> or the <strong>.NET Framework directory</strong>.</p>
<h3>Visual Studio Command Prompt</h3>
<p>To get to the <strong>Visual Studio Command Prompt</strong>, just hit the Start menu and type <strong>Visual Studio Command Prompt</strong> into the finder. If you have Visual Studio installed, you should be able to find this tool.</p>
<h3>.NET Framework Directory</h3>
<p>Alternatively, you can also run these tools from the .NET Framework directory. For .NET 4.0 or 4.5, you&#8217;ll find the tools here: <strong>C:\Windows\Microsoft.NET\Framework\v4.0.30319</strong></p>
<p>Just navigate to that directory in <strong>cmd.exe</strong> or PowerShell.</p>
<h2>Public Key Tokens with sn</h2>
<p>Just run <strong>sn -T</strong> followed by your DLL or assembly. Here&#8217;s an example:</p>
<pre class="bigpowershell">
PS > sn -T "C:\dev\project_name\packages\System.Data.SQLite.1.0.84.0\lib\net45\System.Data.SQLite.dll"

Microsoft (R) .NET Framework Strong Name Utility  Version 3.5.30729.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Public key token is db937bc2d44ff139
</pre>
<h2>Public Key Tokens with gacutil</h2>
<p>If the DLL is in the GAC, you can do the same thing with <strong>gacutil</strong>:</p>
<pre class="bigpowershell">
PS > gacutil -l System.Data.SQLite
Microsoft (R) .NET Global Assembly Cache Utility. Version 4.0.30319.1
Copyright (c) Microsoft Corporation. All rights reserved.

The Global Assembly Cache contains the following assemblies:
System.Data.SQLite, Version=1.0.84.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=AMD64

Number of items = 1
</pre>
<p>Now go get that token you were after!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techblogistech.com/2013/03/how-to-find-public-key-token/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing .NET Framework 4 Client Profile Dependency Issues</title>
		<link>http://www.techblogistech.com/2013/03/net-framework-4-client-profile-dependency-issues/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=net-framework-4-client-profile-dependency-issues</link>
		<comments>http://www.techblogistech.com/2013/03/net-framework-4-client-profile-dependency-issues/#comments</comments>
		<pubDate>Tue, 19 Mar 2013 15:59:37 +0000</pubDate>
		<dc:creator>sean</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[.net framework 4]]></category>
		<category><![CDATA[.net framework 4 client profile]]></category>
		<category><![CDATA[dependencies]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[project properties]]></category>
		<category><![CDATA[structuremap]]></category>
		<category><![CDATA[system.web]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.techblogistech.com/?p=961</guid>
		<description><![CDATA[If you&#8217;ve worked with .NET 4, you might have run into this before. You&#8217;re casually typing and clicking along and &#8230; <span class="more-link"><a href="http://www.techblogistech.com/2013/03/net-framework-4-client-profile-dependency-issues/">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.techblogistech.com/wp-content/uploads/2012/03/microsoft.net_.png" rel="shadowbox[sbpost-961];player=img;"><img class="lazy alignright size-medium wp-image-820" title="microsoft.net" alt="Microsoft .NET" src="http://www.techblogistech.com/wp-content/plugins/jquery-image-lazy-loading/images/grey.gif" data-original="http://www.techblogistech.com/wp-content/uploads/2012/03/microsoft.net_-300x192.png" width="100" height="64" /><noscript><img class="alignright size-medium wp-image-820" title="microsoft.net" alt="Microsoft .NET" src="http://www.techblogistech.com/wp-content/uploads/2012/03/microsoft.net_-300x192.png" width="100" height="64" /></noscript></a>If you&#8217;ve worked with .NET 4, you might have run into this before. You&#8217;re casually typing and clicking along and then you go to add a reference to your project; but suddenly your application won&#8217;t build any more. The error complains about your targeted framework and a Microsoft library dependency. This library is included in .NET, but it won&#8217;t add to my project! What gives?</p>
<pre>
The referenced assembly "StructureMap" could not be resolved because it has a dependency on
"System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which is not in the
currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references
to assemblies not in the targeted framework or consider retargeting your project.
</pre>
<h2>The Problem</h2>
<p>If you take a closer look at the error, you&#8217;ll notice the targeted framework includes the text <strong>Profile=Client</strong>.</p>
<p>The .NET Framework 4 Client Profile is a subset of the .NET Framework 4 that is optimized for client applications; it restricts the set of referenced assemblies to only those that are interesting to a client application. For example, it won&#8217;t make System.Web available by default because it is not typically valuable to client apps.</p>
<p>So if you started building a Forms app (or WCF or WPF), Visual Studio might have defaulted you to target the .NET Framework 4 Client Profile instead of just .NET Framework 4. And now, it&#8217;s complaining because you want to add libraries that a client application doesn&#8217;t typically have any use for.</p>
<h2>The Solution</h2>
<p>Right-click the project that needs the reference added, click properties, and update the project to target .NET Framework 4 instead of the Client Profile.</p>
<p><a href="http://www.techblogistech.com/wp-content/uploads/2013/03/project-properties-dot-net-framework-4.png" rel="shadowbox[sbpost-961];player=img;"><img src="http://www.techblogistech.com/wp-content/plugins/jquery-image-lazy-loading/images/grey.gif" data-original="http://www.techblogistech.com/wp-content/uploads/2013/03/project-properties-dot-net-framework-4.png" alt="Visual Studio Project Properties - .NET Framework 4" width="762" height="313" class="lazy alignnone size-full wp-image-962" /><noscript><img src="http://www.techblogistech.com/wp-content/uploads/2013/03/project-properties-dot-net-framework-4.png" alt="Visual Studio Project Properties - .NET Framework 4" width="762" height="313" class="alignnone size-full wp-image-962" /></noscript></a></p>
<p>Now get back to work!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techblogistech.com/2013/03/net-framework-4-client-profile-dependency-issues/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Fix DataGridView Rows Showing Up Without Data</title>
		<link>http://www.techblogistech.com/2013/03/empty-datagridview-cells/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=empty-datagridview-cells</link>
		<comments>http://www.techblogistech.com/2013/03/empty-datagridview-cells/#comments</comments>
		<pubDate>Sun, 17 Mar 2013 21:44:32 +0000</pubDate>
		<dc:creator>sean</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[cells]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[datagridview]]></category>
		<category><![CDATA[empty]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[properties]]></category>
		<category><![CDATA[public fields]]></category>
		<category><![CDATA[rows]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.techblogistech.com/?p=951</guid>
		<description><![CDATA[The DataGridView is incredibly helpful for binding data sources to a grid, but sometimes working with it is a bit &#8230; <span class="more-link"><a href="http://www.techblogistech.com/2013/03/empty-datagridview-cells/">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.techblogistech.com/wp-content/uploads/2012/03/microsoft.net_.png" rel="shadowbox[sbpost-951];player=img;"><img class="lazy alignright size-medium wp-image-820" title="microsoft.net" alt="Microsoft .NET" src="http://www.techblogistech.com/wp-content/plugins/jquery-image-lazy-loading/images/grey.gif" data-original="http://www.techblogistech.com/wp-content/uploads/2012/03/microsoft.net_-300x192.png" width="100" height="64" /><noscript><img class="alignright size-medium wp-image-820" title="microsoft.net" alt="Microsoft .NET" src="http://www.techblogistech.com/wp-content/uploads/2012/03/microsoft.net_-300x192.png" width="100" height="64" /></noscript></a>The <a title="DataGridView Class from MSDN" href="http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.aspx" target="_blank">DataGridView</a> is incredibly helpful for binding data sources to a grid, but sometimes working with it is a bit tricky. If you use the DataGridView control sparingly (or you&#8217;re just plain forgetful), you might run into an issue where you can see rows in the grid, but all the cells are empty!</p>
<p><a href="http://www.techblogistech.com/wp-content/uploads/2013/03/datagridview-empty-rows.png" rel="shadowbox[sbpost-951];player=img;"><img src="http://www.techblogistech.com/wp-content/plugins/jquery-image-lazy-loading/images/grey.gif" data-original="http://www.techblogistech.com/wp-content/uploads/2013/03/datagridview-empty-rows.png" alt="DataGridView Empty Rows" width="450" height="302" class="lazy alignnone size-full wp-image-953" /><noscript><img src="http://www.techblogistech.com/wp-content/uploads/2013/03/datagridview-empty-rows.png" alt="DataGridView Empty Rows" width="450" height="302" class="alignnone size-full wp-image-953" /></noscript></a></p>
<h2>The Problem</h2>
<p>Not to worry! If you&#8217;re seeing the correct number of rows, you probably just have some visibility problems with the class being used.</p>
<p>In my case, I was trying to bind a list of proxies (<strong>List</strong>) like this:</p>
<pre class="bigbash">private void BindProxyGrid(IList proxies)
{
    var proxiesBindingList = new BindingList(proxies);
    dgvProxies.DataSource = proxiesBindingList;
}</pre>
<p>And my proxy class looked something like this:</p>
<pre class="bigbash">public class Proxy
{
    public string Ip;
    public int Port;
}</pre>
<h2>The Solution</h2>
<p>So why didn&#8217;t it work? Because the DataGridView requires properties and I was using public fields. Updating the class to use properties fixed the problem!</p>
<pre class="bigbash">public class Proxy
{
    public string Ip { get; set; }
    public int Port { get; set; }
}</pre>
<p>It works!</p>
<p><a href="http://www.techblogistech.com/wp-content/uploads/2013/03/datagridview-filled-rows.png" rel="shadowbox[sbpost-951];player=img;"><img src="http://www.techblogistech.com/wp-content/plugins/jquery-image-lazy-loading/images/grey.gif" data-original="http://www.techblogistech.com/wp-content/uploads/2013/03/datagridview-filled-rows.png" alt="DataGridView Filled Rows" width="452" height="303" class="lazy alignnone size-full wp-image-954" /><noscript><img src="http://www.techblogistech.com/wp-content/uploads/2013/03/datagridview-filled-rows.png" alt="DataGridView Filled Rows" width="452" height="303" class="alignnone size-full wp-image-954" /></noscript></a></p>
<h2>The Lesson Learned</h2>
<p>If you&#8217;re using a BindingList with your DataGridView, you may need to adjust the visibility for any class members you want to display in the grid; for example, the DataGridView can&#8217;t access public fields or properties marked internal.</p>
<p>Happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techblogistech.com/2013/03/empty-datagridview-cells/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Normalizing Line Endings Across Multiple Files</title>
		<link>http://www.techblogistech.com/2012/10/normalizing-line-endings-across-multiple-files/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=normalizing-line-endings-across-multiple-files</link>
		<comments>http://www.techblogistech.com/2012/10/normalizing-line-endings-across-multiple-files/#comments</comments>
		<pubDate>Wed, 10 Oct 2012 15:55:47 +0000</pubDate>
		<dc:creator>sean</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[argdo]]></category>
		<category><![CDATA[args]]></category>
		<category><![CDATA[cr]]></category>
		<category><![CDATA[crlf]]></category>
		<category><![CDATA[dos]]></category>
		<category><![CDATA[dos2unix]]></category>
		<category><![CDATA[ffs]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[inconsistent]]></category>
		<category><![CDATA[lf]]></category>
		<category><![CDATA[line endings]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[unix2dos]]></category>
		<category><![CDATA[vim]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.techblogistech.com/?p=913</guid>
		<description><![CDATA[Recently I&#8217;ve been noticing some of my C# files have inconsistent line endings. The Problem The line endings in the &#8230; <span class="more-link"><a href="http://www.techblogistech.com/2012/10/normalizing-line-endings-across-multiple-files/">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.techblogistech.com/wp-content/uploads/2011/07/oxygen-utilities-terminal.png" rel="shadowbox[sbpost-913];player=img;"><img class="lazy alignright size-full wp-image-104" title="Terminal" src="http://www.techblogistech.com/wp-content/plugins/jquery-image-lazy-loading/images/grey.gif" data-original="http://www.techblogistech.com/wp-content/uploads/2011/07/oxygen-utilities-terminal.png" alt="Terminal" width="77" height="77" /><noscript><img class="alignright size-full wp-image-104" title="Terminal" src="http://www.techblogistech.com/wp-content/uploads/2011/07/oxygen-utilities-terminal.png" alt="Terminal" width="77" height="77" /></noscript></a> Recently I&#8217;ve been noticing some of my C# files have inconsistent line endings.</p>
<p><a href="http://www.techblogistech.com/wp-content/uploads/2012/10/visual_studio_inconsistent_line_endings.png" rel="shadowbox[sbpost-913];player=img;"><img src="http://www.techblogistech.com/wp-content/plugins/jquery-image-lazy-loading/images/grey.gif" data-original="http://www.techblogistech.com/wp-content/uploads/2012/10/visual_studio_inconsistent_line_endings.png" alt="Visual Studio: Inconsistent Line Endings" title="Visual Studio: Inconsistent Line Endings" width="447" height="238" class="lazy alignnone size-full wp-image-914" /><noscript><img src="http://www.techblogistech.com/wp-content/uploads/2012/10/visual_studio_inconsistent_line_endings.png" alt="Visual Studio: Inconsistent Line Endings" title="Visual Studio: Inconsistent Line Endings" width="447" height="238" class="alignnone size-full wp-image-914" /></noscript></a></p>
<h2>The Problem</h2>
<pre>
The line endings in the following file are not consistent. Do you want to normalize the line endings?
</pre>
<p>This probably means some of the developers have been editing our source code using a text-editor (instead of Visual Studio) and they had their line endings set to &#8220;Unix&#8221; or &#8220;Mac&#8221; instead of &#8220;Dos/Windows&#8221;. This isn&#8217;t a big deal, though it is annoying.</p>
<h2>Vim: Convert All Files to Dos/Windows Line Endings</h2>
<p>Since I don&#8217;t know which files have this problem, I decided to just normalize all the line endings. There are various ways to do this, but I chose to use <a href="http://www.vim.org/" title="Vim" target="_blank">vim</a> since the <a href="http://vim.wikia.com/wiki/File_format" title="Vim: File Format" target="_blank">documentation on this topic</a> is excellent.</p>
<p>To convert from any mixture of CRLF endings and LF-only endings, to CRLF endings:</p>
<pre class="bash">
:set ffs=dos
:args **\*.cs
:argdo w
</pre>
<p>We&#8217;re basically asking <strong>vim</strong> to assume Dos/Windows line endings, having it open all *.cs files (C# code files), then having it write the line-ending changes.</p>
<h2>Downsides</h2>
<p>This does change every single file that was found, regardless of the original line endings. It&#8217;s best to do this as one commit in source control to avoid any confusion.</p>
<h2>Alternatives</h2>
<p>You can also use <a href="http://en.wikipedia.org/wiki/Unix2dos" title="unix2dos" target="_blank">unix2dos</a> to do this conversion or any scripting language (python, perl, powershell).</p>
<p>Some people also let their source control handle their line endings. <a href="http://git-scm.com/" title="Git" target="_blank">Git</a> can enforce these line endings by updating them for you if you prefer. However, at my office, we choose not to let our source control alter our code in any way; we prefer to do that ourselves. <img src='http://www.techblogistech.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Now get back to coding!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.techblogistech.com/2012/10/normalizing-line-endings-across-multiple-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell Object Tutorial</title>
		<link>http://www.techblogistech.com/2012/05/powershell-object-tutorial/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=powershell-object-tutorial</link>
		<comments>http://www.techblogistech.com/2012/05/powershell-object-tutorial/#comments</comments>
		<pubDate>Sun, 27 May 2012 18:42:20 +0000</pubDate>
		<dc:creator>sean</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[add-member]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[noteproperty]]></category>
		<category><![CDATA[objects]]></category>
		<category><![CDATA[param]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[primer]]></category>
		<category><![CDATA[property]]></category>
		<category><![CDATA[scriptmethod]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[write-host]]></category>

		<guid isPermaLink="false">http://www.techblogistech.com/?p=877</guid>
		<description><![CDATA[Creating objects in PowerShell is&#8230; strange, to put it lightly&#8211;down right awful if you want to be realistic. But even &#8230; <span class="more-link"><a href="http://www.techblogistech.com/2012/05/powershell-object-tutorial/">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.techblogistech.com/wp-content/uploads/2012/02/powershell-logo.png" rel="shadowbox[sbpost-877];player=img;"><img src="http://www.techblogistech.com/wp-content/plugins/jquery-image-lazy-loading/images/grey.gif" data-original="http://www.techblogistech.com/wp-content/uploads/2012/02/powershell-logo.png" alt="Windows Powershell" title="Windows Powershell" width="64" height="64" class="lazy alignright size-full wp-image-771" /><noscript><img src="http://www.techblogistech.com/wp-content/uploads/2012/02/powershell-logo.png" alt="Windows Powershell" title="Windows Powershell" width="64" height="64" class="alignright size-full wp-image-771" /></noscript></a>Creating objects in PowerShell is&#8230; strange, to put it lightly&#8211;down right awful if you want to be realistic.  But even if the syntax is terrible, objects are still nice to use.  Here&#8217;s a quick primer on how to create and use an object in PowerShell.</p>
<h2>Creating a New Object</h2>
<p>First let&#8217;s create an object using <strong>New-Object</strong>.</p>
<pre class="bigpowershell">PS > $myObj = New-Object Object
</pre>
<p><span id="more-877"></span></p>
<h2>Add a Property</h2>
<p>Add a new property to the object by using <strong>Add-Member</strong> and specifying the member type <strong>NoteProperty</strong>.</p>
<pre class="bigpowershell">PS > Add-Member -MemberType NoteProperty -InputObject $myObj -Name MyName -Value "Sean"
PS > $myObj.MyName
Sean
</pre>
<h2>Add a Method</h2>
<p>Add a new method to the object by using <strong>Add-Member</strong> and specifying the member type <strong>ScriptMethod</strong>.  The value should be a <strong>script block</strong>, so put your code in curly braces.</p>
<p>When calling the method, don&#8217;t forget to use parentheses.  When calling cmdlets in PowerShell you don&#8217;t use parentheses, so it&#8217;s easy to forget to do so here.</p>
<pre class="bigpowershell">PS > Add-Member -MemberType ScriptMethod -InputObject $myObj -Name PrintName -Value { Write-Host "My name is" $this.MyName }
PS > $myObj.PrintName()
My name is Sean
</pre>
<h2>Add a Method that Accepts Arguments</h2>
<p>You can use a <strong>param</strong> statement to allow your method to accept arguments.</p>
<p>Don&#8217;t forget to follow each statement with a semicolon since we&#8217;re defining our method on a single line.</p>
<p>When passing the arguments you&#8217;ll need to comma-delimit them; again, this is in contrast to the space-delimited arguments you pass to cmdlets.</p>
<pre class="bigpowershell">PS > Add-Member -MemberType ScriptMethod -InputObject $myObj -Name PrintNameAgeAndInterest -Value { param($age, $interest); Write-Host "My name is" $this.MyName "and I am $age years old. I like $interest!" }
PS > $myObj.PrintNameAgeAndInterest(23, 'programming')
My name is Sean and I am 23 years old. I like programming!
</pre>
<h2>Creating Large Methods</h2>
<p>You don&#8217;t have to create methods all on one line if you don&#8217;t want to.  If you&#8217;re building a script&#8211;and you probably are&#8211;make sufficient use of white space to make your code easier to read.  I personally use the <strong>`</strong> (backtick) to continue my methods on the next line for readability.  Here&#8217;s an example.</p>
<pre class="bigpowershell">Add-Member -MemberType ScriptMethod -InputObject $myObj -Name Print1ThroughX -Value `
{
	param($x)
	for($i = 1; $i -le $x; $i++)
	{
		Write-Host $i
	}
}
</pre>
<p>And look, it works!</p>
<pre class="bigpowershell">PS > $myObj.Print1ThroughX(10)
1
2
3
4
5
6
7
8
9
10
</pre>
<h2>Overwriting Methods</h2>
<p>What if you define a method, but you make a mistake?</p>
<pre class="bigpowershell">PS > Add-Member -MemberType ScriptMethod -InputObject $myObj -Name OutputName -Value { Write-Hst "My name is" $this.MyName }
PS > $myObj.OutputName()
Exception calling "OutputName" with "0" argument(s): "The term 'Write-Hst' is not recognized as the name of a cmdlet,
 function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that t
he path is correct and try again."
At line:1 char:18
+ $myObj.OutputName <<<< ()
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ScriptMethodRuntimeException
</pre>
<p>Oh no!  I misspelled <strong>Write-Host</strong>.  No problem!  Just use the <strong>-Force</strong> attribute to overwrite the method with the corrected version.</p>
<pre class="bigpowershell">PS > Add-Member -Force -MemberType ScriptMethod -InputObject $myObj -Name OutputName -Value { Write-Host "My name is" $this.MyName }
PS > $myObj.OutputName()
My name is Sean
</pre>
<h3>Have fun using objects in PowerShell!</h3>
]]></content:encoded>
			<wfw:commentRss>http://www.techblogistech.com/2012/05/powershell-object-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Fix &#8220;Could not connect to the feed specified&#8221; with NuGet and TeamCity</title>
		<link>http://www.techblogistech.com/2012/05/fix-could-not-connect-to-feed-with-nuget-and-teamcity/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=fix-could-not-connect-to-feed-with-nuget-and-teamcity</link>
		<comments>http://www.techblogistech.com/2012/05/fix-could-not-connect-to-feed-with-nuget-and-teamcity/#comments</comments>
		<pubDate>Tue, 22 May 2012 20:25:16 +0000</pubDate>
		<dc:creator>sean</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[1.7]]></category>
		<category><![CDATA[1.8]]></category>
		<category><![CDATA[2066]]></category>
		<category><![CDATA[21011]]></category>
		<category><![CDATA[builds]]></category>
		<category><![CDATA[ci]]></category>
		<category><![CDATA[dot net]]></category>
		<category><![CDATA[dotnet]]></category>
		<category><![CDATA[feedservice]]></category>
		<category><![CDATA[jetbrains]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[nightly]]></category>
		<category><![CDATA[nuget]]></category>
		<category><![CDATA[nuget.tools.vsix]]></category>
		<category><![CDATA[teamcity]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[vsix]]></category>

		<guid isPermaLink="false">http://www.techblogistech.com/?p=866</guid>
		<description><![CDATA[When using NuGet 1.7 with TeamCity 7, I was receiving an error in the NuGet GUI when trying to connect &#8230; <span class="more-link"><a href="http://www.techblogistech.com/2012/05/fix-could-not-connect-to-feed-with-nuget-and-teamcity/">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.techblogistech.com/wp-content/uploads/2012/05/nugeticon.png" rel="shadowbox[sbpost-866];player=img;"><img src="http://www.techblogistech.com/wp-content/plugins/jquery-image-lazy-loading/images/grey.gif" data-original="http://www.techblogistech.com/wp-content/uploads/2012/05/nugeticon.png" alt="" title="NuGet Icon" width="66" height="62" class="lazy alignright size-full wp-image-868" /><noscript><img src="http://www.techblogistech.com/wp-content/uploads/2012/05/nugeticon.png" alt="" title="NuGet Icon" width="66" height="62" class="alignright size-full wp-image-868" /></noscript></a>When using <a href="http://nuget.org" title="NuGet" target="_blank">NuGet</a> 1.7 with <a href="http://www.jetbrains.com/teamcity/" title="JetBrains TeamCity" target="_blank">TeamCity</a> 7, I was receiving an error in the NuGet GUI when trying to connect to our NuGet feed.  The error in Visual Studio looked like this:</p>
<pre>Could not connect to the feed specified at '$the-server/app/nuget/v1/FeedService.svc'. Please verify the package
source (located in the Package Manager Settings) is valid and ensure your network connectivity.
</pre>
<h1>The solution</h1>
<p>This is a confirmed bug in NuGet 1.7, as seen in both <a href="https://nuget.codeplex.com/workitem/2066" title="NuGet bug 2066" target="_blank">this NuGet bug report (2066)</a> and <a href="http://youtrack.jetbrains.com/issue/TW-21011" title="TeamCity bug 21011" target="_blank">this TeamCity bug report (21011)</a>.  To fix the problem you need to download a newer version of NuGet that contains the bug fix.</p>
<h2>NuGet 1.8</h2>
<p>As of this blog post NuGet 1.8 isn&#8217;t released, but it should be released soon; try updating your plugin to the latest stable version to see if your problem is resolved.</p>
<p><strong>Update: <a href="http://docs.nuget.org/docs/release-notes/nuget-1.8" title="NuGet 1.8 Release Notes" target="_blank">NuGet 1.8</a> has been released!  Upgrade using the Visual Studio Extension Manager or <a href="http://visualstudiogallery.msdn.microsoft.com/27077b70-9dad-4c64-adcf-c7cf6bc9970c" title="NuGet 1.8 Download Page" target="_blank">download it here</a>!</strong></p>
<h2>Nightly builds</h2>
<p>If the latest stable build doesn&#8217;t resolve your issue, you can download a nightly build from <a href="http://ci.nuget.org:8080/overview.html" title="NuGet's CI Server" target="_blank">NuGet&#8217;s CI server</a>.<br />
1. Go to <a href="http://ci.nuget.org:8080/overview.html" title="NuGet's CI Server" target="_blank">NuGet&#8217;s CI server</a><br />
2. Click the link at the bottom to log in as a guest<br />
3. Under the <strong>NuGet</strong> section you&#8217;ll see a couple of options (currently <strong>1.8</strong> and <strong>Default</strong>)<br />
4. Mouse over the <strong>Artifacts</strong> link for whichever build you choose (I chose to download a <strong>1.8</strong> build), click <strong>VisualStudioAddIn</strong> and then <strong>NuGet.Tools.vsix</strong><br />
5. Your download should start; let it finish<br />
6. Probably best to close any open Visual Studio instances<br />
7. Run the vsix installer by double-clicking it</p>
<p>Your new NuGet extension should now be installed and your TeamCity feed URL should now work!</p>
<p>Enjoy NuGetting!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.techblogistech.com/2012/05/fix-could-not-connect-to-feed-with-nuget-and-teamcity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Fix Errors with the PowerShell WebAdministration Module</title>
		<link>http://www.techblogistech.com/2012/05/errors-with-powershell-webadministration-module/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=errors-with-powershell-webadministration-module</link>
		<comments>http://www.techblogistech.com/2012/05/errors-with-powershell-webadministration-module/#comments</comments>
		<pubDate>Tue, 22 May 2012 04:15:08 +0000</pubDate>
		<dc:creator>sean</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[32-bit]]></category>
		<category><![CDATA[64-bit]]></category>
		<category><![CDATA[688EEEE5-6A7E-422F-B2E1-6AF00DC944A6]]></category>
		<category><![CDATA[80040154]]></category>
		<category><![CDATA[clsid]]></category>
		<category><![CDATA[com]]></category>
		<category><![CDATA[COMException]]></category>
		<category><![CDATA[get-website]]></category>
		<category><![CDATA[iis]]></category>
		<category><![CDATA[management service]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[system32]]></category>
		<category><![CDATA[syswow64]]></category>
		<category><![CDATA[webadministration]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.techblogistech.com/?p=857</guid>
		<description><![CDATA[The PowerShell WebAdministration module can be finicky. If you&#8217;re seeing COMException error messages, here are a few things you could &#8230; <span class="more-link"><a href="http://www.techblogistech.com/2012/05/errors-with-powershell-webadministration-module/">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.techblogistech.com/wp-content/uploads/2012/02/powershell-logo.png" rel="shadowbox[sbpost-857];player=img;"><img src="http://www.techblogistech.com/wp-content/plugins/jquery-image-lazy-loading/images/grey.gif" data-original="http://www.techblogistech.com/wp-content/uploads/2012/02/powershell-logo.png" alt="Windows Powershell" title="Windows Powershell" width="64" height="64" class="lazy alignright size-full wp-image-771" /><noscript><img src="http://www.techblogistech.com/wp-content/uploads/2012/02/powershell-logo.png" alt="Windows Powershell" title="Windows Powershell" width="64" height="64" class="alignright size-full wp-image-771" /></noscript></a>The PowerShell <strong>WebAdministration</strong> module can be finicky.  If you&#8217;re seeing COMException error messages, here are a few things you could try.</p>
<h2>WebAdministration Errors</h2>
<p>If you import the module using the <strong>32-bit</strong> version of PowerShell, you might see the following.</p>
<pre class="bigpowershell">PS > Import-Module WebAdministration
PS > Get-Website
Get-Website : Retrieving the COM class factory for component with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed
  due to the following error: 80040154.
At line:1 char:12
+ Get-Website <<<<
    + CategoryInfo          : NotSpecified: (:) [Get-Website], COMException
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.IIs.PowerShell.Provider.GetWebsite
   Command
</pre>
<p>If you import the module using the <strong>64-bit</strong> version of PowerShell, you might see this error.</p>
<pre class="bigpowershell">PS > Import-Module WebAdministration
PS > Get-Website
format-default : Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
    + CategoryInfo          : NotSpecified: (:) [format-default], COMException
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.PowerShell.Commands.FormatDefaultCommand
</pre>
<p><span id="more-857"></span></p>
<h2>Solutions</h2>
<h3>Enable IIS Management Service</h3>
<p>Firstly, you should make sure the <strong>IIS Management Service</strong> is enabled.  To do so, follow these steps:<br />
1. Click <strong>Start</strong> and then click <strong>Control Panel</strong><br />
2. In <strong>Control Panel</strong>, click <strong>Programs</strong> and then click <strong>Turn Windows features on or off</strong>.<br />
3. In the <strong>Windows Features</strong> dialog box, verify that <strong>IIS Management Service</strong> is checked and then click <strong>OK</strong></p>
<p><a href="http://www.techblogistech.com/wp-content/uploads/2012/05/iis_management.png" rel="shadowbox[sbpost-857];player=img;"><img src="http://www.techblogistech.com/wp-content/plugins/jquery-image-lazy-loading/images/grey.gif" data-original="http://www.techblogistech.com/wp-content/uploads/2012/05/iis_management.png" alt="" title="IIS Management Service" width="429" height="375" class="lazy alignnone size-full wp-image-858" /><noscript><img src="http://www.techblogistech.com/wp-content/uploads/2012/05/iis_management.png" alt="" title="IIS Management Service" width="429" height="375" class="alignnone size-full wp-image-858" /></noscript></a></p>
<h3>Try both 32-bit PowerShell and 64-bit PowerShell</h3>
<p>If you're on a 64-bit platform, you have both the 32-bit and 64-bit versions of PowerShell installed.  In my personal experience, <strong>using 64-bit PowerShell worked for me</strong>.  However, people on various internet forums have claimed that the 32-bit version of PowerShell worked for them.  Try running your script from both versions to see which one works for you.</p>
<p><strong>64-bit PowerShell:</strong> C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe<br />
<strong>32-bit PowerShell:</strong> C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe</p>
<h3>Test Script</h3>
<p>To test each version, try running these commands and make sure you don't get errors.</p>
<pre class="bigpowershell">Import-Module WebAdministration
Get-Website
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.techblogistech.com/2012/05/errors-with-powershell-webadministration-module/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Examining and Recursing Objects in PowerShell</title>
		<link>http://www.techblogistech.com/2012/05/examining-and-recursing-objects-in-powershell/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=examining-and-recursing-objects-in-powershell</link>
		<comments>http://www.techblogistech.com/2012/05/examining-and-recursing-objects-in-powershell/#comments</comments>
		<pubDate>Fri, 18 May 2012 01:22:44 +0000</pubDate>
		<dc:creator>sean</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[depth]]></category>
		<category><![CDATA[examining]]></category>
		<category><![CDATA[format-custom]]></category>
		<category><![CDATA[format-list]]></category>
		<category><![CDATA[get-member]]></category>
		<category><![CDATA[membertype]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[objects]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[property]]></category>
		<category><![CDATA[recursing]]></category>
		<category><![CDATA[select-object]]></category>
		<category><![CDATA[static]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.techblogistech.com/?p=849</guid>
		<description><![CDATA[I&#8217;m still somewhat new to PowerShell and all the time I find myself wanting to examine objects to see what &#8230; <span class="more-link"><a href="http://www.techblogistech.com/2012/05/examining-and-recursing-objects-in-powershell/">Continue Reading</a></span>]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.techblogistech.com/wp-content/uploads/2012/02/powershell-logo.png" rel="shadowbox[sbpost-849];player=img;"><img src="http://www.techblogistech.com/wp-content/plugins/jquery-image-lazy-loading/images/grey.gif" data-original="http://www.techblogistech.com/wp-content/uploads/2012/02/powershell-logo.png" alt="Windows Powershell" title="Windows Powershell" width="64" height="64" class="lazy alignright size-full wp-image-771" /><noscript><img src="http://www.techblogistech.com/wp-content/uploads/2012/02/powershell-logo.png" alt="Windows Powershell" title="Windows Powershell" width="64" height="64" class="alignright size-full wp-image-771" /></noscript></a>I&#8217;m still somewhat new to PowerShell and all the time I find myself wanting to examine objects to see what properties and methods they have available.  The documentation on MSDN and around the web is pretty good, but there are still plenty of situations where it&#8217;s just easier or better to <strong>ask</strong> PowerShell to help you out instead.  For instance, when you&#8217;re using a third-party module that&#8217;s sparsely documented you might want to just examine its objects.  Or maybe you just don&#8217;t feel like going to Google.  Either way, here&#8217;s a bunch of ways you can get a better look at an object in PowerShell.</p>
<p><span id="more-849"></span></p>
<h2>An Object To Use</h2>
<p>For example purposes&#8211;in case you want to try any of these out right now&#8211;you can create a list of processes and use that as your object.</p>
<pre class="bigpowershell">PS > $object = Get-Process
</pre>
<p>Feel free to use any object you want though.</p>
<h2>Examining a Single Object</h2>
<pre class="bigpowershell">PS > # List all methods and properties
PS > $object | Get-Member
</pre>
<h2>Examining the Properties of an Object</h2>
<pre class="bigpowershell">PS > # List properties
PS > $object | Get-Member -memberType property
PS > # A few more properties
PS > $object | Get-Member -memberType *property
</pre>
</h2>
<h2>Examining the Properties of an Array Object</h2>
<pre class="bigpowershell">PS > # Brief list of properties on an object or array
PS > $object | Select-Object *
PS > # List properties on each element in the array
PS > $object | Format-List *
PS > # Using -Force on Format-List can sometimes reveal hidden properties
PS > $object | Format-List * -Force
</pre>
<h2>Examining the Methods of an Object</h2>
<pre class="bigpowershell">PS > # List methods
PS > $object | Get-Member -memberType method
PS > # List standard Methods
PS > $object | Get-Member -memberType *method | Where-Object { $_.Name -notlike '*_*' }
PS > # List static Methods
PS > $object | Get-Member -static -memberType *method
</pre>
<h2>Recursively Examining an Object</h2>
<p>This is really useful for objects that contain other objects or when you&#8217;re having a tough time figuring out how to drill down into an object to get the data you want.</p>
<pre class="bigpowershell">PS > # Recursively examine the object to a depth of 5
PS > $object | Format-Custom * -Depth 5
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.techblogistech.com/2012/05/examining-and-recursing-objects-in-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
