<?xml version="1.0" encoding="utf-8"?>
<!-- generator="wordpress/2.1" -->
<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/"
	>

<channel>
	<title>George Tsiokos' blog</title>
	<link>http://george.tsiokos.com</link>
	<description>on c#, .NET, SharePoint, Windows and OS X</description>
	<pubDate>Thu, 09 Oct 2008 13:51:07 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.1</generator>
	<language>en</language>
			<item>
		<title>LINQ to SQL produces incorrect TSQL when using UNION or CONCAT</title>
		<link>http://george.tsiokos.com/posts/2008/09/10/linq-to-sql-produces-incorrect-tsql-when-using-union-or-concat/</link>
		<comments>http://george.tsiokos.com/posts/2008/09/10/linq-to-sql-produces-incorrect-tsql-when-using-union-or-concat/#comments</comments>
		<pubDate>Wed, 10 Sep 2008 20:50:09 +0000</pubDate>
		<dc:creator>George Tsiokos</dc:creator>
		
		<category><![CDATA[.NET]]></category>

		<category><![CDATA[Bugs]]></category>

		<category><![CDATA[LINQ]]></category>

		<guid isPermaLink="false">http://george.tsiokos.com/posts/2008/09/10/linq-to-sql-produces-incorrect-tsql-when-using-union-or-concat/</guid>
		<description><![CDATA[When a LINQ to SQL query contains a Union or Concat with a second query, and the second query references a column twice, a SqlException will occur.
var a = from address in dc.Addresses
select new {
ID = address.AddressID,
Address1 = address.AddressLine1,
Address2 = address.AddressLine2,
};
var b = from address in dc.Addresses
select new {
ID = address.AddressID,
Address1 = address.AddressLine1,
Address2 = address.AddressLine1, [...]]]></description>
			<content:encoded><![CDATA[<p>When a LINQ to SQL query contains a Union or Concat with a second query, and the second query references a column twice, a SqlException will occur.</p>
<pre>var a = from address in dc.Addresses
select new {
ID = address.AddressID,
Address1 = address.AddressLine1,
Address2 = address.AddressLine2,
};
var b = from address in dc.Addresses
select new {
ID = address.AddressID,
Address1 = address.AddressLine1,
Address2 = address.AddressLine1, // notice AddressLine1 repeated
};
var q = a.Take(10).Union (b.Take(10));
q.ToArray ();</pre>
<p>SqlException: <strong>All the queries in a query expression containing a UNION operator must have the same number of expressions in their select lists.</strong></p>
<pre>SELECT [t2].[AddressID] AS [ID], [t2].[AddressLine1] AS [Address1], [t2].[AddressLine2] AS [Address2]
FROM (
SELECT TOP (10) [t0].[AddressID], [t0].[AddressLine1], [t0].[AddressLine2]
FROM [Person].[Address] AS [t0]
UNION
SELECT TOP (10) [t1].[AddressID], [t1].[AddressLine1]
FROM [Person].[Address] AS [t1]
) AS [t2]</pre>
<p><em>Notice the third SELECT statement is only selecting two columns instead of the required three.</em></p>
<p>Please <a href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=355734">rate and validate</a> this bug at the MSDN Microsoft Product Feedback Center so Microsoft responds with a solution or workaround.</p>
]]></content:encoded>
			<wfw:commentRss>http://george.tsiokos.com/posts/2008/09/10/linq-to-sql-produces-incorrect-tsql-when-using-union-or-concat/feed/</wfw:commentRss>
		</item>
		<item>
		<title>LINQ to SQL - code generation bug</title>
		<link>http://george.tsiokos.com/posts/2008/04/09/linq-to-sql-code-generation-bug/</link>
		<comments>http://george.tsiokos.com/posts/2008/04/09/linq-to-sql-code-generation-bug/#comments</comments>
		<pubDate>Wed, 09 Apr 2008 21:23:38 +0000</pubDate>
		<dc:creator>George Tsiokos</dc:creator>
		
		<category><![CDATA[.NET]]></category>

		<category><![CDATA[Bugs]]></category>

		<category><![CDATA[LINQ]]></category>

		<guid isPermaLink="false">http://george.tsiokos.com/posts/2008/04/09/linq-to-sql-code-generation-bug/</guid>
		<description><![CDATA[The code generation performed by MSLinqToSQLGenerator or SQLMetal generates weird property code. For example, in AdvantureWorks, the table Product has a column ProductLine. Using the tools that come with LINQ to SQL, this column translates to a property:
[Column(Storage="_ProductLine", DbType="NChar(2)")]
public string ProductLine
{
  get
  {
    return this._ProductLine;
  }
  set
  [...]]]></description>
			<content:encoded><![CDATA[<p>The code generation performed by MSLinqToSQLGenerator or SQLMetal generates weird property code. For example, in AdvantureWorks, the table Product has a column ProductLine. Using the tools that come with LINQ to SQL, this column translates to a property:</p>
<pre>[Column(Storage="_ProductLine", DbType="NChar(2)")]
public string ProductLine
{
  get
  {
    return this._ProductLine;
  }
  set
  {
    if ((this._ProductLine != value)) {
      this.OnProductLineChanging(value);
      this.SendPropertyChanging();
      this._ProductLine = value;
      this.SendPropertyChanged("ProductLine");
      this.OnProductLineChanged();
    }
  }
}</pre>
<p>The odd code involves the SendPropertyChanging() method call. This method call should pass the name of the property, just like the SendPropertyChanged() method call, according to the <a href="http://msdn2.microsoft.com/en-us/library/system.componentmodel.propertychangingeventargs.propertychangingeventargs.aspx">documentation</a>. Another interesting detail: The OnProductLineChanging and OnProductLineChanged partial method calls are out of order:
<ol>
<li>Call OnProductLineChanging() partial method</li>
<li>Raise PropertyChanging event, but don’t tell which property is changing – send an empty string instead</li>
<li>Set the property’s field’s value to the specified new value</li>
<li>Raise PropertyChanged event and specify which property is changing</li>
<li>Call OnProductLineChanged() partial method</li>
</ol>
<p>Why is the PropertyChanged event raised before calling the OnProductLineChanged partial method?</p>
<p>All classes created by LINQ to SQL add the following protected methods:</p>
<pre>
protected virtual void SendPropertyChanging() {
  if ((this.PropertyChanging != null)) {
    this.PropertyChanging(this, emptyChangingEventArgs);
  }
}
protected virtual void SendPropertyChanged(String propertyName) {
  if ((this.PropertyChanged != null)) {
    this.PropertyChanged(this,
        new PropertyChangedEventArgs(propertyName));
  }
}</pre>
<p>Again, what’s odd about this code is how the SendPropertyChanging() method does not have a property name parameter and sends a emptyChangingEventArgs field reference to the PropertyChanging event rather than creating a new instance of the EventArgs like the SendPropertyChanged() method call does. By creating a new instance of the EventArgs in SendPropertyChanged, it’s able to pass the property name in the constructor (like the documentation says it should).</p>
<p>Here is the field that is passed to all invocations of the event:</p>
<pre>private static PropertyChangingEventArgs emptyChangingEventArgs =
  new PropertyChangingEventArgs(String.Empty);</pre>
<p>As you can see from this constructor, the property that is changing is an <strong>empty string</strong>. Given the fact that this is a private field and should not be modified by extension methods, it’s odd that this field is not static readonly.</p>
<p>My guess is that the code is generated incorrectly to account for a data-binding or allocation problem. I’ve come to this conclusion by the emptyChangingEventArgs field – it reduces the object instance creation in half for each property change when there are event consumers for the changing event. The big disadvantage for event consumers is that they doesn’t know which property is changing on an object instance.</p>
<p>One alternative is to use <a href="http://www.codeplex.com/codesmith">PLINQO</a>, which creates the properties correctly.</p>
<p><strong>UPDATE</strong>: I have found that this <a href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=290470">has already been reported</a>. Unfortunately, Microsoft has closed this bug and said it was by design, even though the generated code does not follow Microsoft&#8217;s documentation for the <a href="http://msdn2.microsoft.com/en-us/library/system.componentmodel.propertychangingeventargs.aspx">PropertyChangingEventArgs</a> class.</p>
]]></content:encoded>
			<wfw:commentRss>http://george.tsiokos.com/posts/2008/04/09/linq-to-sql-code-generation-bug/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SqlMetal.exe crashes when a column name in the result set is [ ].</title>
		<link>http://george.tsiokos.com/posts/2007/11/28/sqlmetal-crashes-when-a-column-name-in-the-result-set-is-blank/</link>
		<comments>http://george.tsiokos.com/posts/2007/11/28/sqlmetal-crashes-when-a-column-name-in-the-result-set-is-blank/#comments</comments>
		<pubDate>Wed, 28 Nov 2007 23:46:35 +0000</pubDate>
		<dc:creator>George Tsiokos</dc:creator>
		
		<category><![CDATA[.NET]]></category>

		<category><![CDATA[Bugs]]></category>

		<guid isPermaLink="false">http://george.tsiokos.com/posts/2007/11/28/sqlmetal-crashes-when-a-column-name-is/</guid>
		<description><![CDATA[The last message to be written to the console was: “Error : Index was outside the bounds of the array.”.
To reproduce this bug, create this stored procedure and run SqlMetal against it:
CREATE PROCEDURE [dbo].[ThisProcedureWillCauseSqlMetalToCrash] AS
BEGIN
	SET NOCOUNT ON;
	SELECT 1 [A], 2 [ ], 3 [C]
END
Applies to:

Visual Studio 2008 RTM
Microsoft Windows SDK v6.0A

Please rate and validate this [...]]]></description>
			<content:encoded><![CDATA[<p>The last message to be written to the console was: “Error : Index was outside the bounds of the array.”.</p>
<p>To reproduce this bug, create this stored procedure and run SqlMetal against it:<br />
<code>CREATE PROCEDURE [dbo].[ThisProcedureWillCauseSqlMetalToCrash] AS<br />
BEGIN<br />
	SET NOCOUNT ON;<br />
	SELECT 1 [A], 2 [ ], 3 [C]<br />
END</code></p>
<p>Applies to:</p>
<ul>
<li>Visual Studio 2008 RTM</li>
<li>Microsoft Windows SDK v6.0A</li>
</ul>
<p>Please rate and validate this problem at the <a href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=313167">MSDN Microsoft Product Feedback Center</a> so Microsoft responds with a solution or workaround.</p>
]]></content:encoded>
			<wfw:commentRss>http://george.tsiokos.com/posts/2007/11/28/sqlmetal-crashes-when-a-column-name-in-the-result-set-is-blank/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Some Enterprise Library 3.0 - April 2007 bug fixes</title>
		<link>http://george.tsiokos.com/posts/2007/05/21/some-enterprise-library-30-april-2007-bug-fixes/</link>
		<comments>http://george.tsiokos.com/posts/2007/05/21/some-enterprise-library-30-april-2007-bug-fixes/#comments</comments>
		<pubDate>Mon, 21 May 2007 13:11:18 +0000</pubDate>
		<dc:creator>George Tsiokos</dc:creator>
		
		<category><![CDATA[.NET]]></category>

		<category><![CDATA[Bugs]]></category>

		<guid isPermaLink="false">http://george.tsiokos.com/posts/2007/05/21/some-enterprise-library-30-april-2007-bug-fixes/</guid>
		<description><![CDATA[Here are the bug fixes I wrote for Enterprise Library 3.0 - April 2007, related to using the EntLibLoggingProxyTraceListener to proxy .NET TraceListener messages to enterprise library and logging over MSMQ via MsmqTraceListener.
In Microsoft. Practices. EnterpriseLibrary. Logging. TraceListeners. EntLibLoggingProxyTraceListener, comment out
properties.Add(TraceEventCacheKey, eventCache); // line 66 &#038; 146 (fix for SerializationException)
In Microsoft. Practices. EnterpriseLibrary. Logging. TraceListeners. [...]]]></description>
			<content:encoded><![CDATA[<p>Here are the bug <em>fixes </em>I wrote for Enterprise Library 3.0 - April 2007, related to using the EntLibLoggingProxyTraceListener to proxy .NET TraceListener messages to enterprise library and logging over MSMQ via MsmqTraceListener.</p>
<p>In Microsoft. Practices. EnterpriseLibrary. Logging. TraceListeners. EntLibLoggingProxyTraceListener, comment out<br />
<code>properties.Add(TraceEventCacheKey, eventCache); // line 66 &#038; 146 (fix for SerializationException)</code><br />
In Microsoft. Practices. EnterpriseLibrary. Logging. TraceListeners. MsmqTraceListener, change<code>	queueMessage.Label = messageLabel;</code><br />
to<code>	queueMessage.Label = string.IsNullOrEmpty (messageLabel) ? string.Empty : messageLabel; // line 153 (fix for ArgumentNullException)</code><br />
In LoggingDatabase.sql, change <code>	[Title] [nvarchar](256) NOT NULL,</code><br />
to <code>	[Title] [nvarchar](256) NULL,</code></p>
]]></content:encoded>
			<wfw:commentRss>http://george.tsiokos.com/posts/2007/05/21/some-enterprise-library-30-april-2007-bug-fixes/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Internal NullReferenceException in HttpWebRequest when using a CachePolicy</title>
		<link>http://george.tsiokos.com/posts/2007/03/15/nullreferenceexception_httpwebrequest_cachepolicy/</link>
		<comments>http://george.tsiokos.com/posts/2007/03/15/nullreferenceexception_httpwebrequest_cachepolicy/#comments</comments>
		<pubDate>Thu, 15 Mar 2007 05:02:47 +0000</pubDate>
		<dc:creator>George Tsiokos</dc:creator>
		
		<category><![CDATA[.NET]]></category>

		<category><![CDATA[c#]]></category>

		<category><![CDATA[Bugs]]></category>

		<guid isPermaLink="false">http://george.tsiokos.com/posts/2007/03/15/nullreferenceexception_httpwebrequest_cachepolicy/</guid>
		<description><![CDATA[Setting the CachePolicy to the default HttpRequestCacheLevel causes an exception internal to HttpWebRequest when a web application is running with an application pool configured to use a custom identity. For example:
HttpWebRequest request = …;
request.CachePolicy =
  new System.Net.Cache.HttpRequestCachePolicy (
    System.Net.Cache.HttpRequestCacheLevel.Default);
request.GetResponse ();
GetResponse () throws a WebException: “The request was aborted: The request was [...]]]></description>
			<content:encoded><![CDATA[<p>Setting the CachePolicy to the default HttpRequestCacheLevel causes an exception internal to HttpWebRequest when a web application is running with an application pool <a href="http://msdn2.microsoft.com/en-us/library/ms998297.aspx">configured to use a custom identity</a>. For example:</p>
<pre>HttpWebRequest request = …;
request.CachePolicy =
  new System.Net.Cache.HttpRequestCachePolicy (
    System.Net.Cache.HttpRequestCacheLevel.Default);
request.GetResponse ();</pre>
<p>GetResponse () throws a WebException: “The request was aborted: The request was canceled.” Inner exception shows that the private method CheckCacheUpdateOnResponse () of System.Net.HttpWebRequest encounters a NullReferenceException.</p>
<p>A “workaround” would involve loading the user’s profile. For example, if the application pool custom identity is DOMAIN\MyWebApp, log in to the server as MyWebApp. The error goes away – until the profile is unloaded.</p>
<p>This problem does not occur when the web application is using the default application pool identity, NetworkService, because I believe that profile is already loaded by default.</p>
<p>Another <a href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=98156">bug report</a> is somewhat similar to this but only manifests after <em>a few thousand</em> requests. These are probably symptoms of a much larger bug (or design flaw – http request caching is currently implemented through IE’s cache).</p>
<p><strong>Update</strong>: Microsoft has <a href="https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=263447">reproduced this bug</a> and will be addressing it in a future release.</p>
]]></content:encoded>
			<wfw:commentRss>http://george.tsiokos.com/posts/2007/03/15/nullreferenceexception_httpwebrequest_cachepolicy/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SxS does not support configuration namespace in app.config files</title>
		<link>http://george.tsiokos.com/posts/2006/01/12/sxs/</link>
		<comments>http://george.tsiokos.com/posts/2006/01/12/sxs/#comments</comments>
		<pubDate>Fri, 13 Jan 2006 03:15:38 +0000</pubDate>
		<dc:creator>George Tsiokos</dc:creator>
		
		<category><![CDATA[.NET]]></category>

		<category><![CDATA[Bugs]]></category>

		<guid isPermaLink="false">http://george.tsiokos.com/posts/2006/01/12/sxs/</guid>
		<description><![CDATA[If the configuration namespace is referenced in an app.config, you may receive the following error messages in the system event log:

Syntax error in manifest or policy file file name on line 2. The manifest file root element must be assembly.
The application failed to launch because of an invalid manifest.
Generate Activation Context failed for file name.Manifest. [...]]]></description>
			<content:encoded><![CDATA[<p>If the configuration namespace is referenced in an app.config, you may receive the following error messages in the system event log:</p>
<ul>
<li>Syntax error in manifest or policy file <em>file name</em> on line 2. The manifest file root element must be assembly.</li>
<li>The application failed to launch because of an invalid manifest.</li>
<li>Generate Activation Context failed for <em>file name</em>.Manifest. Reference error message: The operation completed successfully.</li>
</ul>
<p>You may also receive this message box:</p>
<ul>
<li>The operation could not be completed. This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem.</li>
</ul>
<p>If you were using a beta version of Visual Studio 2005, you may have the configuration namespace, <strong>http://schemas.microsoft.com/.NetConfiguration/v2.0</strong>, referenced in your app.config. This is not supported by SxS, so you application will fail to load when you create an application manifest, or attempt to use ClickOnce.</p>
<p>Please rate and validate this problem at the <a href="http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=ab317f30-b5d2-470d-a345-0116a93b9364">MSDN Microsoft Product Feedback Center</a> so Microsoft responds with a solution or workaround.</p>
]]></content:encoded>
			<wfw:commentRss>http://george.tsiokos.com/posts/2006/01/12/sxs/feed/</wfw:commentRss>
		</item>
		<item>
		<title>ClickOnce does not support mandatory user profiles</title>
		<link>http://george.tsiokos.com/posts/2006/01/12/clickonce-does-not-support-mandatory-user-profiles/</link>
		<comments>http://george.tsiokos.com/posts/2006/01/12/clickonce-does-not-support-mandatory-user-profiles/#comments</comments>
		<pubDate>Fri, 13 Jan 2006 02:46:32 +0000</pubDate>
		<dc:creator>George Tsiokos</dc:creator>
		
		<category><![CDATA[.NET]]></category>

		<category><![CDATA[Windows]]></category>

		<category><![CDATA[Bugs]]></category>

		<category><![CDATA[ClickOnce]]></category>

		<guid isPermaLink="false">http://george.tsiokos.com/posts/2006/01/12/clickonce-does-not-support-mandatory-user-profiles/</guid>
		<description><![CDATA[When attempting to install a ClickOnce application when using mandatory user profiles, you may receive an error message similar to the following:

The manifest may not be valid or the file could not be opened
Manifest XML signature is not valid
The profile for the user is a temporary profile

Please rate and validate this problem at the MSDN [...]]]></description>
			<content:encoded><![CDATA[<p>When attempting to install a ClickOnce application when using mandatory user profiles, you may receive an error message similar to the following:</p>
<ul>
<li>The manifest may not be valid or the file could not be opened</li>
<li>Manifest XML signature is not valid</li>
<li><strong>The profile for the user is a temporary profile</strong></li>
</ul>
<p>Please rate and validate this problem at the <a href="http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=8eba2e10-e890-428c-b4e4-6ad54f347c0d">MSDN Microsoft Product Feedback Center</a> so Microsoft responds with a solution or workaround.</p>
]]></content:encoded>
			<wfw:commentRss>http://george.tsiokos.com/posts/2006/01/12/clickonce-does-not-support-mandatory-user-profiles/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
