.NET 3.5 SP1 breaks use of WPF under IIS - by stusmith

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


27
0
Sign in
to vote
ID 361469 Comments
Status Closed Workarounds
Type Bug Repros 16
Opened 8/12/2008 9:20:59 AM
Access Restriction Public

Description

We have a website, hosted under IIS and running ASP.NET, that uses WPF to generate images on-the-fly. All was well until .NET 3.5 SP1 came out and we tried it on a test server.

With the .NET service pack in place, any attempt to use WPF when running under IIS results in an exception:

A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in PresentationCore.dll

Additional information: The program issued a command but the command length is incorrect. (Exception from HRESULT: 0x80070018)

Stacktrace:

PresentationCore.dll!MS.Internal.HRESULT.Check(int hr) + 0x1f bytes	
PresentationCore.dll!System.Windows.Media.MediaSystem.Startup(System.Windows.Media.MediaContext mc) + 0x150 bytes	
PresentationCore.dll!System.Windows.Media.MediaContext.MediaContext(System.Windows.Threading.Dispatcher dispatcher) + 0x224 bytes	
PresentationCore.dll!System.Windows.Media.MediaContext.From(System.Windows.Threading.Dispatcher dispatcher) + 0x5c bytes	
PresentationCore.dll!System.Windows.Media.Visual.VerifyAPIReadWrite() + 0x1a bytes	
PresentationCore.dll!System.Windows.Media.VisualCollection.Add(System.Windows.Media.Visual visual) + 0x1c bytes	
PresentationFramework.dll!System.Windows.Controls.Viewbox.InternalChild.set(System.Windows.UIElement value) + 0x36 bytes	
PresentationFramework.dll!System.Windows.Controls.Viewbox.Child.set(System.Windows.UIElement value) + 0x3f bytes	
SiteBuilder.DLL!BinaryComponents.SiteBuilder.Website.Code.Images.CrossFadeResourceTransform.Generate.AnonymousMethod()
SiteBuilder.DLL!BinaryComponents.SiteBuilder.Website.Code.Images.BitmapUtility.ThreadFunc(object state = {BinaryComponents.SiteBuilder.Website.Code.Images.BitmapUtility.ThreadState})
mscorlib.dll!System.Threading.ExecutionContext.runTryCode(object userData) + 0x178 bytes	
[Native to Managed Transition]	
[Managed to Native Transition]	
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x62 bytes	
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart(object obj) + 0x5d bytes	
[Appdomain Transition]	

(NB I've entered this as SP1 Beta as there isn't a version entry for the full SP1).

Running the web application under the local development web server, or under .NET 3.5 no-sp works fine. Running under IIS and .NET 3.5 SP1 fails.
Sign in to post a comment.
Posted by BryanLivingston on 1/29/2009 at 10:55 AM
This patch works great.

I've found that when an unhandled exception is thrown in the STA thread it crashes IIS, which brings the site down for a minutes while it takes a core dump.

Here's a message from the windows event log. This particular error happens once every few thousand times.

An unhandled exception occurred and the process was terminated.

Application ID: /LM/W3SVC/5/ROOT

Process ID: 7116

Exception: System.ComponentModel.Win32Exception

Message: The system cannot find the file specified

StackTrace:    at MS.Win32.UnsafeNativeMethods.RegisterClassEx(WNDCLASSEX_D wc_d)
at MS.Win32.HwndWrapper..ctor(Int32 classStyle, Int32 style, Int32 exStyle, Int32 x, Int32 y, Int32 width, Int32 height, String name, IntPtr parent, HwndWrapperHook[] hooks)
at System.Windows.Media.MediaContextNotificationWindow.CreateNotificationWindow(MediaContext ownerMediaContext)
at System.Windows.Media.MediaContext..ctor(Dispatcher dispatcher)
at System.Windows.Media.MediaContext.From(Dispatcher dispatcher)
at System.Windows.Media.Effects.BitmapEffect..ctor()
at System.Windows.Media.Effects.DropShadowBitmapEffect..ctor()
at VectorButtons.Renderer.Render(Button button, Boolean renderMouseOver, Geometry textGeometry) in C:\Users\Livingston\Projects\LT\Vector\Vector.Buttons\Renderer.cs:line 122
at VectorButtons.Renderer.Render(Button button, Boolean renderMouseOver) in C:\Users\Livingston\Projects\LT\Vector\Vector.Buttons\Renderer.cs:line 53
at Cooltext.ButtonRenderer.<>c__DisplayClass1.<RenderButton>b__0()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Posted by zolale on 12/23/2008 at 1:13 AM
Thanks for the update. Worked like a charm!
Posted by Bart de Vries on 12/19/2008 at 4:09 AM
Thumbs up! I have installed the Vista updates and it works great!

Thanx so far!
Posted by Dennis Cheng [MSFT] on 12/17/2008 at 11:10 PM
The package containing fixes for NET3.5sp1 for Windows Vista, Windows 2008 Server are now available here:

x86: http://www.microsoft.com/downloads/details.aspx?familyid=b9de7937-2c12-4f16-ad66-a31b83931953
x64: http://www.microsoft.com/downloads/details.aspx?familyid=98e83614-c30a-4b75-9e05-0a9c3fbdd20d
IA64: http://www.microsoft.com/downloads/details.aspx?familyid=c6adc586-2518-404b-8973-e1e22c556af4

Posted by Bart de Vries on 12/10/2008 at 1:12 AM
ow damn... that takes some time! Currently we are using stupid workarounds for this problem and that makes working not really easy. Is it possible to distribute the fix separately??
Posted by Dennis Cheng [MSFT] on 12/4/2008 at 6:53 PM
Update: the NET 3.5sp1 fixes will be available from Windows Update mid-February 2009
Posted by Dennis Cheng [MSFT] on 11/7/2008 at 4:50 PM
John, the patch for this specific bug and other bugs recently found in .NET 3.5sp1 will be available for download late December.
Posted by John Rzeszotarski on 11/6/2008 at 12:46 PM
Yea any word yet guys, I cannot seem to get past my issue unless we change the architecture around quite a bit. Would really like an update and maybe... gulp... wait for it, a date we can get this fix?
Posted by Bart de Vries on 11/5/2008 at 10:52 AM
Hi Dennis,
Any update on this one? Can't wait to get it fixed!

Bart
Posted by Dennis Cheng [MSFT] on 10/23/2008 at 5:59 PM
Brian07: Correct, it will fix the WPF crash in all services including IIS7 on all versions of Windows Vista . The fix will also be included in the .NET 3.5sp1 package that is distributed from Windows Update.
Posted by zolale on 10/20/2008 at 2:06 AM
We are having the same problem (CruiseControl.NET / Win2008 / IIS7 / .NET 3.5 SP1). All unit tests that test WPF controls crash in the same way. The work around mentioned here earlier didn't do the trick for us, so we are forced to run CC.NET from the command line (not as a service). This enables us to run the unit tests, but creates all kinds of other problems on the the busy build server...
Posted by BrianHearn on 10/15/2008 at 8:42 AM
Dennis--
Just to confirm...the fix that is in "final testing" will resolve WPF execution within IIS7 (not just windows services) - right?
Posted by Dennis Cheng [MSFT] on 10/13/2008 at 12:11 PM
The patch is now in the final testing phase. I will reply back once it has shipped.
Posted by BrianHearn on 10/13/2008 at 7:11 AM
Still no news? We heard there was a fix going through several weeks ago. This issue is litterally holding up the release of our flagship product...I can't tell you how badly we need this to get resolved. I know Microsoft is working dilligently on this and so all I can do is plead our situation and hope this will be resolved soon. If not, I need to know.
Posted by NDRiley on 8/28/2008 at 2:47 PM
Same here (IIS & WPF).
I'm left in the position of advising customers to choose 2003 server rather than 2008.
I hope this is fixed soon.
Posted by Bart de Vries on 8/26/2008 at 11:33 PM
I am also renedering images on the fly using IIS, ASP.NET, C# and WPF and experience the same problem but I am not able te apply the workaround.

What service should be started in XP compatible mode?
All windows services I tried say the compatibility mode can not be changes because it is part of windows.

Regards, Bart
Posted by David Gardiner on 8/25/2008 at 10:44 PM
I take that back.. After I clicked on the 'Show settings for all users' button and set it there, it looks like the workaround is happening.

-dave
Posted by David Gardiner on 8/25/2008 at 7:07 PM
I tried the workaround but I'm still getting the same error running CruiseControl.NET as a service.

I stopped the service, set the compatiblity to XP SP2, then restarted, but the problem persists.

Very annoying,

-dave
Posted by Gerhard Schneider - WPF on 8/25/2008 at 10:22 AM
The problem is caused by an interop problem with the DWM. By forcing the process to "Windows XP SP2", WPF skips the "handshake" with the DWM which avoids the issue.
Posted by David A Nelson on 8/25/2008 at 9:26 AM
Gerhard,

Since the bug specifically mentions that the problem is with using WPF under IIS, how does your proposed workaround solve the problem?
Posted by Gerhard Schneider - WPF on 8/22/2008 at 3:07 PM
We are still investigating a potential fix for this issue. In the meantime, you should be able to work-around the crash by running your service in "Windows XP SP2" compatibility mode. To do this, right click on your service’s executable and select “Properties”. Select the "Compatibility" tab and click on the "Show settings for all users" button. Enable "Run this program in compatibility mode" and choose "Windows XP SP2" from the drop down. Apply the changes and restart your service. You should not see the crash anymore.

Note that changing the compatibility mode might have other side effects. Also note that WPF has not been tested to run inside of a system service. Depending on what you are doing, your mileage may vary.
Posted by Microsoft on 8/13/2008 at 1:57 AM
We were able to reproduce the issue you are seeing. We are escalating this bug to the product unit who works on that specific feature area. The product team will review this issue and make a decision on whether they will fix it or not for the next release
Posted by Microsoft on 8/13/2008 at 1:00 AM
Thank you for your feedback, We are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com/)