<?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 on Tour &#187; cforbes</title>
	<atom:link href="http://www.techontour.com/author/colin/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.techontour.com</link>
	<description>Your resource for Technology News, Reviews and Tutorials</description>
	<lastBuildDate>Fri, 09 Dec 2011 17:47:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Fixing The given assembly name or codebase was invalid.</title>
		<link>http://www.techontour.com/sitenews/2007/11/02/fixing-the-given-assembly-name-or-codebase-was-invalid/</link>
		<comments>http://www.techontour.com/sitenews/2007/11/02/fixing-the-given-assembly-name-or-codebase-was-invalid/#comments</comments>
		<pubDate>Fri, 02 Nov 2007 14:43:31 +0000</pubDate>
		<dc:creator>cforbes</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Site News]]></category>

		<guid isPermaLink="false">http://www.techontour.com/sitenews/2007/11/02/fixing-the-given-assembly-name-or-codebase-was-invalid/</guid>
		<description><![CDATA[I&#8217;m in the process of learning vs2005.net. Every once in a while I run into a problem that makes me run to Google. This is no exception. I wanted to validate the the asp.net CheckBoxList control to make sure that at least one item from the list was checked. I found this wonderful sample code [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m in the process of learning vs2005.net.  Every once in a while I run into a problem that makes me run to Google.  This is no exception.  I wanted to validate the the asp.net CheckBoxList control to make sure that at least one item from the list was checked.  I found this wonderful <a href="http://www.4guysfromrolla.com/webtech/tips/t040302-1.shtml" title="sample code">sample code</a> from 4 Guys from Rolla.com on how to create a custom validation control for this purpose.   After creating a new C# custom control you need to register it with VisualStudio (which places the dll) in the &#8216;bin&#8217; directory of your web site.  4 Guys then show that you need to register the tag prefix that you will be using the <strong>@ Register </strong>directive as shown below:</p>
<p><code>&lt;%@ Register TagPrefix="CustomValidators" Namespace="CustomValidators" Assembly="<em>filename_of_DLL_file</em>" %&gt;</code></p>
<p>Which I change to:</p>
<p><code><font size="2">&lt;%<font size="2" color="#0000ff">@</font><font size="2"> </font><font size="2" color="#a31515">Register</font><font size="2"> </font><font size="2" color="#ff0000">TagPrefix</font><font size="2" color="#0000ff">="cv"</font><font size="2"> </font><font size="2" color="#ff0000">Namespace</font><font size="2" color="#0000ff">="MyCustomValidators"</font><font size="2"> </font><font size="2" color="#ff0000">Assembly</font><font size="2" color="#0000ff">="~/bin/CustomValidationControls.dll"</font><font size="2"> %&gt;</font></font></code></p>
<p>However as soon as I compiled the page I received: <strong>The given assembly name or codebase was invalid. (Exception from HRESULT: 0&#215;80131047)</strong> After searching Google some more I wasn&#8217;t any better off with a solution.  What is wrong with my code base?  Recompiling didn&#8217;t help renaming it didn&#8217;t help.  However after some careful reading of the on-line help related to the @ Register directive I found this statement:</p>
<blockquote><dt><strong>assembly</strong> </dt>
<dd>The assembly in which the namespace that you are associating with the <strong>tagprefix</strong> attribute resides.</p>
<table width="100%" cellPadding="0" cellSpacing="0">
<tr>
<th align="left">Note</th>
</tr>
<tr>
<td>The assembly name does not include a file extension. &#8230;</td>
</tr>
</table>
</dd>
</blockquote>
<p>That was the clue I need combined with another post I had read.  I had added the full path and extension for the assembly but what it was looking for was <strong>ONLY </strong>the <strong>assembly name</strong> it self <strong>with no extension or directory path</strong>.  .net <em>assumes</em> that the path for the assembly will be the <strong>bin</strong> directory. So the correct @ <strong>Register</strong> directive should be:</p>
<p><code><font size="2">&lt;%<font size="2" color="#0000ff">@</font><font size="2"> </font><font size="2" color="#a31515">Register</font><font size="2"> </font><font size="2" color="#ff0000">TagPrefix</font><font size="2" color="#0000ff">="cv"</font><font size="2"> </font><font size="2" color="#ff0000">Namespace</font><font size="2" color="#0000ff">="MyCustomValidators"</font><font size="2"> </font><font size="2" color="#ff0000">Assembly</font><font size="2" color="#0000ff">="CustomValidationControls"</font><font size="2"> %&gt;</font></font></code> </p>
<p>As soon as I did that the page compiled with out errors and I now can <strong>validate my CheckBoxList</strong>.</p>
<p>As an aside note you can also solve this by putting the source file in the App_Code directory and then register the tag prefix this way:</p>
<p><code>&lt;%<font size="2" color="#0000ff">@</font><font size="2"> </font><font size="2" color="#800000">Register</font><font size="2"> </font><font size="2" color="#ff0000">TagPrefix</font><font size="2" color="#0000ff">="cv"</font><font size="2"> </font><font size="2" color="#ff0000">Namespace</font><font size="2" color="#0000ff">="MyCustomValidators"</font><font size="2"> </font><font size="2" color="#ff0000">Assembly</font><font size="2" color="#0000ff">="__Code"</font><font size="2"> %&gt;</font></code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.techontour.com/sitenews/2007/11/02/fixing-the-given-assembly-name-or-codebase-was-invalid/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

