Configuring IIS To Support WPF .XBAP Express Applications With The Dec CTP
I recently needed the script to set the MIME types and forgot where it was; figured I'd blog it in case others needed it. However, this script isn't quite right so I fixed it below. There is a typo, which causes the script to fail. You need to add a comma to the end of line 11. And, I added the new .xbap extension instead of the old .wba. Here's the correct script, below:
'This script adds the necessary "Avalon" MIME types to an IIS Server.
'To use this script, just double-click or execute it from a command line.
'Running this script multiple times results in multiple entries in the IIS MimeMap.
Dim MimeMapObj, MimeMapArray, MimeTypesToAddArray, WshShell, oExec
Const ADS_PROPERTY_UPDATE = 2
'Set the MIME types to be added
MimeTypesToAddArray = Array(".manifest", "application/manifest", _
".xaml", "application/xaml+xml", ".application", "application/x-ms-application", ".deploy", "application/octet-stream", _
".xbap", "application/x-ms-xbap")
'Get the mimemap object
Set MimeMapObj = GetObject("IIS://LocalHost/MimeMap")
'Call AddMimeType for every pair of extension/MIME type
For counter = 0 to UBound(MimeTypesToAddArray) Step 2
AddMimeType MimeTypesToAddArray(counter), MimeTypesToAddArray(counter+1)
Next
'Create a Shell object
Set WshShell = CreateObject("WScript.Shell")
'Stop and Start the IIS Service
Set oExec = WshShell.Exec("net stop w3svc")
Do While oExec.Status = 0
WScript.Sleep 100
Loop
Set oExec = WshShell.Exec("net start w3svc")
Do While oExec.Status = 0
WScript.Sleep 100
Loop
Set oExec = Nothing
'Report status to user
WScript.Echo "Avalon MIME types have been registered."
'AddMimeType Sub
Sub AddMimeType (Ext, MType)
'Get the mappings from the MimeMap property.
MimeMapArray = MimeMapObj.GetEx("MimeMap")
' Add a new mapping.
i = UBound(MimeMapArray) + 1
Redim Preserve MimeMapArray(i)
Set MimeMapArray(i) = CreateObject("MimeMap")
MimeMapArray(i).Extension = Ext
MimeMapArray(i).MimeType = MType
MimeMapObj.PutEx ADS_PROPERTY_UPDATE, "MimeMap", MimeMapArray
MimeMapObj.SetInfo
End Sub
Comments
Anonymous
January 25, 2007
说来也奇怪。在本机为WPF/E项目搭建虚拟目录网站之后WPF/E的项目就一直无法正常显示图像(类似通过http://ip/wpf)。但通过LocalHost的方式确是正常。折腾了几分钟,确定应该是II...Anonymous
March 12, 2007
A few people said this was a showstopper for them in recommneding Office 2007 to their customers so IAnonymous
October 28, 2007
PingBack from http://duitwithsbs.wordpress.com/2007/10/28/how-to-get-companyweb-windows-sharepoint-services-v2-to-work-with-office-2007-david-overtons-blog/Anonymous
June 07, 2009
PingBack from http://evsworld.selfip.info/blog/2009/06/how-to-get-companyweb-windows-sharepoint-services-v2-to-work-with-office-2007/