{"id":3254,"date":"2010-03-03T19:12:56","date_gmt":"2010-03-03T19:12:56","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/webdev\/2010\/03\/03\/how-to-package-and-deploy-com-component\/"},"modified":"2010-03-03T19:12:56","modified_gmt":"2010-03-03T19:12:56","slug":"how-to-package-and-deploy-com-component","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/how-to-package-and-deploy-com-component\/","title":{"rendered":"How to package and deploy COM component"},"content":{"rendered":"<p>I\u2019ll use a walkthrough example to show how to package a web application with speech API COM component using Visual Studio 2010.&#160; I wrote and tested the sample in Win7 x86 with IIS7.5, and packaged and manually installed to win2k3 x86 IIS6 (which only had 3.5 framework installed).<\/p>\n<p>1. Create a C# 3.5 web application<\/p>\n<p>2. Add COM reference to \u201cMicrosoft Speech Object Library\u201d<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/image_2.png\"><img decoding=\"async\" style=\"border-right-width: 0px;border-top-width: 0px;border-bottom-width: 0px;border-left-width: 0px\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2010\/03\/image_thumb-1.png\" width=\"498\" height=\"288\" \/><\/a> <\/p>\n<p>3. In Default.aspx, add the following between &lt;div&gt;<\/p>\n<pre class=\"code\">        <span style=\"color: blue\">&lt;<\/span><span style=\"color: maroon\">asp<\/span><span style=\"color: blue\">:<\/span><span style=\"color: maroon\">ScriptManager <\/span><span style=\"color: red\">ID<\/span><span style=\"color: blue\">=&quot;ScriptManager1&quot; <\/span><span style=\"color: red\">runat<\/span><span style=\"color: blue\">=&quot;server&quot;&gt;\n        &lt;\/<\/span><span style=\"color: maroon\">asp<\/span><span style=\"color: blue\">:<\/span><span style=\"color: maroon\">ScriptManager<\/span><span style=\"color: blue\">&gt;\n        &lt;<\/span><span style=\"color: maroon\">asp<\/span><span style=\"color: blue\">:<\/span><span style=\"color: maroon\">UpdatePanel <\/span><span style=\"color: red\">ID<\/span><span style=\"color: blue\">=&quot;UpdatePanel1&quot; <\/span><span style=\"color: red\">runat<\/span><span style=\"color: blue\">=&quot;server&quot;&gt;\n            &lt;<\/span><span style=\"color: maroon\">ContentTemplate<\/span><span style=\"color: blue\">&gt;\n                &lt;<\/span><span style=\"color: maroon\">asp<\/span><span style=\"color: blue\">:<\/span><span style=\"color: maroon\">TextBox <\/span><span style=\"color: red\">ID<\/span><span style=\"color: blue\">=&quot;TextBox1&quot; <\/span><span style=\"color: red\">runat<\/span><span style=\"color: blue\">=&quot;server&quot; <\/span><span style=\"color: red\">Width<\/span><span style=\"color: blue\">=&quot;274px&quot;&gt;<\/span>Welcome to web deployment<span style=\"color: blue\">&lt;\/<\/span><span style=\"color: maroon\">asp<\/span><span style=\"color: blue\">:<\/span><span style=\"color: maroon\">TextBox<\/span><span style=\"color: blue\">&gt;\n                &lt;<\/span><span style=\"color: maroon\">asp<\/span><span style=\"color: blue\">:<\/span><span style=\"color: maroon\">Button <\/span><span style=\"color: red\">ID<\/span><span style=\"color: blue\">=&quot;Button1&quot; <\/span><span style=\"color: red\">runat<\/span><span style=\"color: blue\">=&quot;server&quot; <\/span><span style=\"color: red\">onclick<\/span><span style=\"color: blue\">=&quot;Button1_Click&quot; \n                    <\/span><span style=\"color: red\">Text<\/span><span style=\"color: blue\">=&quot;Play the text&quot; \/&gt;\n                &lt;<\/span><span style=\"color: maroon\">asp<\/span><span style=\"color: blue\">:<\/span><span style=\"color: maroon\">PlaceHolder <\/span><span style=\"color: red\">ID<\/span><span style=\"color: blue\">=&quot;PlaceHolder1&quot; <\/span><span style=\"color: red\">runat<\/span><span style=\"color: blue\">=&quot;server&quot;&gt;&lt;\/<\/span><span style=\"color: maroon\">asp<\/span><span style=\"color: blue\">:<\/span><span style=\"color: maroon\">PlaceHolder<\/span><span style=\"color: blue\">&gt;\n            &lt;\/<\/span><span style=\"color: maroon\">ContentTemplate<\/span><span style=\"color: blue\">&gt;\n        &lt;\/<\/span><span style=\"color: maroon\">asp<\/span><span style=\"color: blue\">:<\/span><span style=\"color: maroon\">UpdatePanel<\/span><span style=\"color: blue\">&gt;\n<\/span><\/pre>\n<p><a href=\"http:\/\/11011.net\/software\/vspaste\"><\/a><\/p>\n<p>4. In Default.aspx.cs, write the following:<\/p>\n<pre class=\"code\"><span style=\"color: blue\">using <\/span>System;\n<span style=\"color: blue\">using <\/span>System.Collections.Generic;\n<span style=\"color: blue\">using <\/span>System.Linq;\n<span style=\"color: blue\">using <\/span>System.Web;\n<span style=\"color: blue\">using <\/span>System.Web.UI;\n<span style=\"color: blue\">using <\/span>System.Web.UI.WebControls;\n<span style=\"color: blue\">using <\/span>SpeechLib;\n\n<span style=\"color: blue\">namespace <\/span>WebApplication2\n{\n    <span style=\"color: blue\">public partial class <\/span><span style=\"color: #2b91af\">Default <\/span>: System.Web.UI.<span style=\"color: #2b91af\">Page\n    <\/span>{\n        <span style=\"color: blue\">protected void <\/span>Page_Load(<span style=\"color: blue\">object <\/span>sender, <span style=\"color: #2b91af\">EventArgs <\/span>e)\n        {\n            <span style=\"color: blue\">if <\/span>(!<span style=\"color: #2b91af\">String<\/span>.IsNullOrEmpty(Request.Params[<span style=\"color: #a31515\">&quot;text&quot;<\/span>]))\n            {\n                Response.Buffer = <span style=\"color: blue\">false<\/span>;\n\n                <span style=\"color: blue\">byte<\/span>[] byteBuffer = MyTextToWav(Request.Params[<span style=\"color: #a31515\">&quot;text&quot;<\/span>]);\n                Response.Clear();\n                Response.ClearHeaders();\n                Response.ClearContent();\n                \n                Response.AppendHeader(<span style=\"color: #a31515\">&quot;Content-Disposition&quot;<\/span>, <span style=\"color: #a31515\">&quot;attachment;filename=&quot; <\/span>+ <span style=\"color: #2b91af\">HttpUtility<\/span>.UrlEncode(TextBox1.Text + <span style=\"color: #a31515\">&quot;.wav&quot;<\/span>, System.Text.<span style=\"color: #2b91af\">Encoding<\/span>.UTF8));\n                Response.ContentType = <span style=\"color: #a31515\">&quot;audio\/wav&quot;<\/span>;\n                Response.BinaryWrite(byteBuffer);\n                Response.End();\n            }\n        }\n\n        <span style=\"color: blue\">private byte<\/span>[] MyTextToWav(<span style=\"color: blue\">string <\/span>inputText)\n        {\n            <span style=\"color: blue\">byte<\/span>[] b = <span style=\"color: blue\">null<\/span>;\n            {\n                <span style=\"color: #2b91af\">SpMemoryStream <\/span>spMemStream = <span style=\"color: blue\">new <\/span><span style=\"color: #2b91af\">SpMemoryStream<\/span>();\n\n                <span style=\"color: green\">\/\/default value is spMemStream.Format.Type = SpeechAudioFormatType.SAFT22kHz16BitMono;\n                <\/span>SpeechLib.<span style=\"color: #2b91af\">SpVoice <\/span>ispvoice1 = <span style=\"color: blue\">new <\/span><span style=\"color: #2b91af\">SpVoice<\/span>();\n                ispvoice1.AudioOutputStream = spMemStream;\n\n                <span style=\"color: green\">\/\/Note, in IIS, the app pool has to be using LocalSystem to access speechLib COM\n                <\/span>ispvoice1.Speak(inputText, <span style=\"color: #2b91af\">SpeechVoiceSpeakFlags<\/span>.SVSFDefault);\n                ispvoice1.WaitUntilDone(10000);\n                spMemStream.Seek(0, <span style=\"color: #2b91af\">SpeechStreamSeekPositionType<\/span>.SSSPTRelativeToStart);\n\n                <span style=\"color: blue\">byte<\/span>[] buffer = (<span style=\"color: blue\">byte<\/span>[])spMemStream.GetData();\n                <span style=\"color: blue\">using <\/span>(System.IO.<span style=\"color: #2b91af\">MemoryStream <\/span>memoryStream = <span style=\"color: blue\">new <\/span>System.IO.<span style=\"color: #2b91af\">MemoryStream<\/span>())\n                {\n                    System.IO.<span style=\"color: #2b91af\">BinaryWriter <\/span>writer = <span style=\"color: blue\">new <\/span>System.IO.<span style=\"color: #2b91af\">BinaryWriter<\/span>(memoryStream);\n\n                    HeaderWrite(writer, <span style=\"color: blue\">false<\/span>, 16, buffer.Length \/ 2, 22100);  <span style=\"color: green\">\/\/Hack, only works if default as SAFT22kHz16BitMono\n                    \/\/HeaderWrite(writer, false, 16, buffer.Length \/ 2, 44100);\n                    <\/span>writer.Write(buffer);\n\n                    b = memoryStream.GetBuffer();\n                }\n            }\n            <span style=\"color: blue\">return <\/span>b;\n        }\n\n        <span style=\"color: blue\">private void <\/span>HeaderWrite(System.IO.<span style=\"color: #2b91af\">BinaryWriter <\/span>writer, <span style=\"color: blue\">bool <\/span>stereo, <span style=\"color: blue\">short <\/span>bitsPerSample, <span style=\"color: blue\">int <\/span>numberOfSamples, <span style=\"color: blue\">int <\/span>sampleRate)\n        {\n            writer.Write(0x46464952); <span style=\"color: green\">\/\/ &quot;RIFF&quot; in ASCII\n            <\/span>writer.Write((<span style=\"color: blue\">int<\/span>)(44 + (numberOfSamples * bitsPerSample * (stereo ? 2 : 1) \/ 8)) - 8);\n            writer.Write(0x45564157); <span style=\"color: green\">\/\/ &quot;WAVE&quot; in ASCII\n\n            <\/span>writer.Write(0x20746d66); <span style=\"color: green\">\/\/ &quot;fmt &quot; in ASCII\n            <\/span>writer.Write(16);\n            writer.Write((<span style=\"color: blue\">short<\/span>)1);\n            writer.Write((<span style=\"color: blue\">short<\/span>)(stereo ? 2 : 1));\n            writer.Write(sampleRate);\n            writer.Write(sampleRate * (stereo ? 2 : 1) * bitsPerSample \/ 8);\n            writer.Write((<span style=\"color: blue\">short<\/span>)((stereo ? 2 : 1) * bitsPerSample \/ 8));\n            writer.Write(bitsPerSample);\n\n            writer.Write(0x61746164); <span style=\"color: green\">\/\/ &quot;data&quot; in ASCII\n            <\/span>writer.Write((<span style=\"color: blue\">int<\/span>)(numberOfSamples * bitsPerSample * (stereo ? 2 : 1) \/ 8));\n        } \n\n        <span style=\"color: blue\">protected void <\/span>Button1_Click(<span style=\"color: blue\">object <\/span>sender, <span style=\"color: #2b91af\">EventArgs <\/span>e)\n        {\n            <span style=\"color: blue\">try\n            <\/span>{\n                Response.Redirect(<span style=\"color: #2b91af\">String<\/span>.Format(<span style=\"color: #a31515\">&quot;Default.aspx?&amp;text={0}&quot;<\/span>, TextBox1.Text ));<span style=\"color: green\">\n            <\/span>}\n            <span style=\"color: blue\">catch <\/span>(<span style=\"color: #2b91af\">Exception <\/span>ex)\n            {\n                PlaceHolder1.Controls.Add(<span style=\"color: blue\">new <\/span><span style=\"color: #2b91af\">LiteralControl<\/span>(ex.ToString()));\n            }\n        }\n    }\n}<\/pre>\n<p><a href=\"http:\/\/11011.net\/software\/vspaste\"><\/a><\/p>\n<p>5. Ctrl-F5 and test, it should work fine with ASP.NET Development Server.<\/p>\n<p>6. Right click the project name in solution explorer, and choose \u201cBuild Deployment Package\u201d, it should build a debug package inside project\u2019s objdebugpackage directory.&#160; <\/p>\n<p>7. In a admin command prompt, we can go to that directory, and deploy the package locally to IIS by running \u201c&lt;ProjectName&gt;.deploy.cmd \/y\u201d.&#160; Note, we can also publish it using publish dialog by using localhost as the service URL.<\/p>\n<p>8. Since SpeechAPI does not work with IIS application pools that runs with \u201cNetwork Service\u201d or \u201cApplicationPoolIdentity\u201d, we\u2019ve to add a new 2.0 application pool, and set its identity to \u201cLocalSystem\u201d.&#160; Then set the deployed website\u2019s application pool to use it.&#160; Test it out, it should work in IIS7 as well.&#160; (Security risk, make sure you change it back after demo.)<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/image_4.png\"><img decoding=\"async\" style=\"border-right-width: 0px;border-top-width: 0px;border-bottom-width: 0px;border-left-width: 0px\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2010\/03\/image_thumb_1-1.png\" width=\"283\" height=\"349\" \/><\/a> <a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/16\/2019\/02\/image_6.png\"><img decoding=\"async\" style=\"border-right-width: 0px;border-top-width: 0px;border-bottom-width: 0px;border-left-width: 0px\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2010\/03\/image_thumb_2-1.png\" width=\"428\" height=\"341\" \/><\/a> <\/p>\n<p>9. Let\u2019s try to package and deploy to a win2k3 machine.&#160; To install the corresponding Speech API on the win2k3 machine, I can download\/install Microsoft Speech SDK, or copy the corresponding speech API dll from my win7 machine and do regsvr32 on the machine.&#160; But for demonstrating purpose, I decide to use <a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/dd569107(WS.10).aspx\">web deploy&#160; provider comObject32<\/a><strong><\/strong> to package the COM component along with my application, so that the package can be easily deployed to many win2k3 machines.&#160; We extend our project similarly to the one stated in the <a href=\"http:\/\/blogs.msdn.com\/webdevtools\/archive\/2010\/02\/09\/how-to-extend-target-file-to-include-registry-settings-for-web-project-package.aspx\">how to package registry blog<\/a>.&#160; The extended projectName.wpp.targets file looks like following:<\/p>\n<pre class=\"code\"><span style=\"color: blue\">&lt;!--<\/span><span style=\"color: green\">******************************************************************** <\/span><span style=\"color: blue\">--&gt;\n&lt;!-- <\/span><span style=\"color: green\">Task CollectcomObjectForPackage <\/span><span style=\"color: blue\">--&gt;\n&lt;!-- <\/span><span style=\"color: green\">comObject32 Provider reference: http:\/\/technet.microsoft.com\/en-us\/library\/dd569107(WS.10).aspx <\/span><span style=\"color: blue\">--&gt;\n&lt;!-- <\/span><span style=\"color: green\">comObject64 Provider reference: http:\/\/technet.microsoft.com\/en-us\/library\/dd569022(WS.10).aspx <\/span><span style=\"color: blue\">--&gt;\n&lt;!--<\/span><span style=\"color: green\">********************************************************************<\/span><span style=\"color: blue\">--&gt;\n&lt;<\/span><span style=\"color: #a31515\">Project <\/span><span style=\"color: red\">xmlns<\/span><span style=\"color: blue\">=<\/span>&quot;<span style=\"color: blue\">http:\/\/schemas.microsoft.com\/developer\/msbuild\/2003<\/span>&quot;<span style=\"color: blue\">&gt;\n  &lt;<\/span><span style=\"color: #a31515\">PropertyGroup<\/span><span style=\"color: blue\">&gt;\n    &lt;!--<\/span><span style=\"color: green\">Targets get execute before this Target<\/span><span style=\"color: blue\">--&gt;\n    &lt;<\/span><span style=\"color: #a31515\">OnBeforeCollectcomObjectForPackage <\/span><span style=\"color: red\">Condition<\/span><span style=\"color: blue\">=<\/span>&quot;<span style=\"color: blue\">'$(OnBeforeCollectcomObjectForPackage)'==''<\/span>&quot;<span style=\"color: blue\">&gt;\n    &lt;\/<\/span><span style=\"color: #a31515\">OnBeforeCollectcomObjectForPackage<\/span><span style=\"color: blue\">&gt;\n    &lt;!--<\/span><span style=\"color: green\">Targets get execute after this Target<\/span><span style=\"color: blue\">--&gt;\n    &lt;<\/span><span style=\"color: #a31515\">OnAfterCollectcomObjectForPackage <\/span><span style=\"color: red\">Condition<\/span><span style=\"color: blue\">=<\/span>&quot;<span style=\"color: blue\">'$(OnAfterCollectcomObjectForPackage)'==''<\/span>&quot;<span style=\"color: blue\">&gt;\n    &lt;\/<\/span><span style=\"color: #a31515\">OnAfterCollectcomObjectForPackage<\/span><span style=\"color: blue\">&gt;\n\n    &lt;<\/span><span style=\"color: #a31515\">CollectcomObjectForPackageDependsOn <\/span><span style=\"color: red\">Condition<\/span><span style=\"color: blue\">=<\/span>&quot;<span style=\"color: blue\">'$(CollectcomObjectForPackageDependsOn)'==''<\/span>&quot;<span style=\"color: blue\">&gt;\n      <\/span>$(OnBeforeCollectcomObjectForPackage);\n      Build;\n    <span style=\"color: blue\">&lt;\/<\/span><span style=\"color: #a31515\">CollectcomObjectForPackageDependsOn<\/span><span style=\"color: blue\">&gt;\n  &lt;\/<\/span><span style=\"color: #a31515\">PropertyGroup<\/span><span style=\"color: blue\">&gt;\n\n  &lt;<\/span><span style=\"color: #a31515\">PropertyGroup<\/span><span style=\"color: blue\">&gt;\n    &lt;<\/span><span style=\"color: #a31515\">IncludecomObjectForMyProject <\/span><span style=\"color: red\">Condition<\/span><span style=\"color: blue\">=<\/span>&quot;<span style=\"color: blue\">'$(IncludecomObjectForMyProject)'==''<\/span>&quot;<span style=\"color: blue\">&gt;<\/span>False<span style=\"color: blue\">&lt;\/<\/span><span style=\"color: #a31515\">IncludecomObjectForMyProject<\/span><span style=\"color: blue\">&gt;\n    &lt;<\/span><span style=\"color: #a31515\">MyComObject32s <\/span><span style=\"color: red\">Condition<\/span><span style=\"color: blue\">=<\/span>&quot;<span style=\"color: blue\">'$(MyComObject32s)'==''<\/span>&quot;<span style=\"color: blue\">&gt;&lt;\/<\/span><span style=\"color: #a31515\">MyComObject32s<\/span><span style=\"color: blue\">&gt;\n    &lt;<\/span><span style=\"color: #a31515\">AfterAddContentPathToSourceManifest <\/span><span style=\"color: red\">Condition<\/span><span style=\"color: blue\">=<\/span>&quot;<span style=\"color: blue\">'$(AfterAddContentPathToSourceManifest)'==''<\/span>&quot;<span style=\"color: blue\">&gt;\n      <\/span>$(AfterAddContentPathToSourceManifest);\n      CollectcomObjectForPackage;\n    <span style=\"color: blue\">&lt;\/<\/span><span style=\"color: #a31515\">AfterAddContentPathToSourceManifest<\/span><span style=\"color: blue\">&gt;\n  &lt;\/<\/span><span style=\"color: #a31515\">PropertyGroup<\/span><span style=\"color: blue\">&gt;\n\n  &lt;<\/span><span style=\"color: #a31515\">ItemGroup<\/span><span style=\"color: blue\">&gt;\n    &lt;<\/span><span style=\"color: #a31515\">MycomObject <\/span><span style=\"color: red\">Include <\/span><span style=\"color: blue\">= <\/span>&quot;<span style=\"color: blue\">$(MyComObject32s)<\/span>&quot;<span style=\"color: blue\">\/&gt;\n  &lt;\/<\/span><span style=\"color: #a31515\">ItemGroup<\/span><span style=\"color: blue\">&gt;\n\n  &lt;<\/span><span style=\"color: #a31515\">Target <\/span><span style=\"color: red\">Name<\/span><span style=\"color: blue\">=<\/span>&quot;<span style=\"color: blue\">CollectcomObjectForPackage<\/span>&quot;\n          <span style=\"color: red\">DependsOnTargets<\/span><span style=\"color: blue\">=<\/span>&quot;<span style=\"color: blue\">$(CollectcomObjectForPackageDependsOn)<\/span>&quot;\n          <span style=\"color: red\">Condition<\/span><span style=\"color: blue\">=<\/span>&quot;<span style=\"color: blue\">$(IncludecomObjectForMyProject) AND '$(MyComObject32s)'!=''<\/span>&quot;<span style=\"color: blue\">&gt;\n\n    &lt;<\/span><span style=\"color: #a31515\">Message <\/span><span style=\"color: red\">Text<\/span><span style=\"color: blue\">=<\/span>&quot;<span style=\"color: blue\">Adding %(MycomObject.Identity)<\/span>&quot; <span style=\"color: blue\">\/&gt;\n    &lt;<\/span><span style=\"color: #a31515\">ItemGroup<\/span><span style=\"color: blue\">&gt;\n      &lt;<\/span><span style=\"color: #a31515\">MsDeploySourceManifest <\/span><span style=\"color: red\">Include<\/span><span style=\"color: blue\">=<\/span>&quot;<span style=\"color: blue\">comObject32<\/span>&quot;\n                                 <span style=\"color: red\">Condition<\/span><span style=\"color: blue\">=<\/span>&quot;<span style=\"color: blue\">$(IncludecomObjectForMyProject)<\/span>&quot;<span style=\"color: blue\">&gt;\n        &lt;<\/span><span style=\"color: #a31515\">Path<\/span><span style=\"color: blue\">&gt;<\/span>%(MycomObject.Identity)<span style=\"color: blue\">&lt;\/<\/span><span style=\"color: #a31515\">Path<\/span><span style=\"color: blue\">&gt;\n      &lt;\/<\/span><span style=\"color: #a31515\">MsDeploySourceManifest<\/span><span style=\"color: blue\">&gt;\n    &lt;\/<\/span><span style=\"color: #a31515\">ItemGroup<\/span><span style=\"color: blue\">&gt;\n    &lt;<\/span><span style=\"color: #a31515\">CallTarget <\/span><span style=\"color: red\">Targets<\/span><span style=\"color: blue\">=<\/span>&quot;<span style=\"color: blue\">$(OnAfterCollectcomObjectForPackage)<\/span>&quot; <span style=\"color: red\">RunEachTargetSeparately<\/span><span style=\"color: blue\">=<\/span>&quot;<span style=\"color: blue\">false<\/span>&quot; <span style=\"color: blue\">\/&gt;\n  &lt;\/<\/span><span style=\"color: #a31515\">Target<\/span><span style=\"color: blue\">&gt;\n&lt;\/<\/span><span style=\"color: #a31515\">Project<\/span><span style=\"color: blue\">&gt;\n\n<\/span><\/pre>\n<p><a href=\"http:\/\/11011.net\/software\/vspaste\"><\/a><\/p>\n<p>10. On my sample win2k3 machine, I manually copied WindowsSystem32SpeechCommonsapi.dll and did a registry export before and after regsvr32 it.&#160; It turns out we need to include many registry node for speech API COM component.&#160; I put it in the following package command line (really long).&#160; Run it, you get a package with the speech API COM component.<\/p>\n<p>msbuild WebApplication5.csproj \/target:package \/p:IncludecomObjectForMyProject=True;MyComObject32s=&quot;SAPI.SpAudioFormat;SAPI.SpAudioFormat.1;SAPI.SpCompressedLexicon;SAPI.SpCompressedLexicon.1;SAPI.SpCustomStream;SAPI.SpCustomStream.1;SAPI.SpDataKey;SAPI.SpDataKey.1;SAPI.SpFileStream;SAPI.SpFileStream.1;SAPI.SpGramCompBackEnd;SAPI.SpGramCompBackEnd.1;SAPI.SpGrammarCompiler;SAPI.SpGrammarCompiler.1;SAPI.SpInProcRecoContext;SAPI.SpInProcRecoContext.1;SAPI.SpInprocRecognizer;SAPI.SpInprocRecognizer.1;SAPI.SpITNProcessor;SAPI.SpITNProcessor.1;SAPI.SpLexicon;SAPI.SpLexicon.1;SAPI.SpMemoryStream;SAPI.SpMemoryStream.1;SAPI.SpMMAudioEnum;SAPI.SpMMAudioEnum.1;SAPI.SpMMAudioIn;SAPI.SpMMAudioIn.1;SAPI.SpMMAudioOut;SAPI.SpMMAudioOut.1;SAPI.SPNotify;SAPI.SPNotify.1;SAPI.SpNotifyTranslator;SAPI.SpNotifyTranslator.1;SAPI.SpNullPhoneConverter;SAPI.SpNullPhoneConverter.1;SAPI.SpObjectToken;SAPI.SpObjectToken.1;SAPI.SpObjectTokenCategory;SAPI.SpObjectTokenCategory.1;SAPI.SpObjectTokenEnum;SAPI.SpObjectTokenEnum.1;SAPI.SpPhoneConverter;SAPI.SpPhoneConverter.1;SAPI.SpPhrase;SAPI.SpPhrase.1;SAPI.SpPhraseBuilder;SAPI.SpPhraseBuilder.1;SAPI.SpPhraseInfoBuilder;SAPI.SpPhraseInfoBuilder.1;SAPI.SpResourceManager;SAPI.SpResourceManager.1;SAPI.SpSharedRecoContext;SAPI.SpSharedRecoContext.1;SAPI.SpSharedRecognizer;SAPI.SpSharedRecognizer.1;SAPI.SpShortcut;SAPI.SpShortcut.1;SAPI.SpStream;SAPI.SpStream.1;SAPI.SpStreamFormatConverter;SAPI.SpStreamFormatConverter.1;SAPI.SpTextSelectionInformation;SAPI.SpTextSelectionInformation.1;SAPI.SpUncompressedLexicon;SAPI.SpUncompressedLexicon.1;SAPI.SpVoice;SAPI.SpVoice.1;SAPI.SpWaveFormatEx;SAPI.SpWaveFormatEx.1;SAPIEngine.TTSEngine;SAPIEngine.TTSEngine.1;{1B2AFB92-0B5E-4A30-B5CC-353DB4F9E150};{1B57B2A1-E763-4676-9064-297F1B413632};{2D12DD17-6C4E-456E-A953-D210E3C64176};{4C6F940C-3CFE-11D2-9EE7-00C04F797396};{4F414126-DFE3-4629-99EE-797978317EAD};{9CDAEA40-A7D3-4CC5-AED0-B5E35AD0F169};{C02F29F0-DFCA-4DC1-8B80-ED3216E1B5E0};{CA0AC604-8EF2-448A-AE97-62A2C2CC3C46};{D2C13906-51EF-454E-BC67-A52475FF074C};{D36D2090-4DF3-4BD4-A22F-0D91975F7964};{D6AD10F3-70AB-41E1-96B3-4C36E35D333C};{DC626A64-D684-4627-83CB-44420ABDBD1A};{F3D3F924-11FC-11D3-BB97-00C04F8EE6C0}&quot;<\/p>\n<p>11. copy the package and deploy command file to win2k3 x86 machine with IIS6, using \u201c&lt;ProjectName&gt;.deploy.cmd \/y\u201d from command line. <\/p>\n<p>12. In IIS Manager, make sure the new deployed website is running with asp.net 2.0.&#160; Create a new application pool and change its Identity to \u201cLocal System\u201d (Security risk, make sure you change it back after demo).&#160; Assign the deployed website to use this application pool.&#160; Test it out, it should work.<\/p>\n<p>&#160;<\/p>\n<p>Note, for IIS7 to IIS7 package and deployment, we can include the application pool setting so that when deploy, a new application pool will be created (or existing be overwritten if app pool name already exists) and \u201cLocal System\u201d is granted as identity. (VS2010 beta1 version\u2019s topic is in <a title=\"http:\/\/blogs.msdn.com\/webdevtools\/archive\/2009\/02\/09\/web-packaging-creating-a-web-package-using-vs-2010.aspx\" href=\"http:\/\/blogs.msdn.com\/webdevtools\/archive\/2009\/02\/09\/web-packaging-creating-a-web-package-using-vs-2010.aspx\">http:\/\/blogs.msdn.com\/webdevtools\/archive\/2009\/02\/09\/web-packaging-creating-a-web-package-using-vs-2010.aspx<\/a> , the UI has changed a bit, but still the same mostly.)<\/p>\n<p>&#160;<\/p>\n<p>Xinyang Qiu | Visual Web Developer<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I\u2019ll use a walkthrough example to show how to package a web application with speech API COM component using Visual Studio 2010.&#160; I wrote and tested the sample in Win7 x86 with IIS7.5, and packaged and manually installed to win2k3 x86 IIS6 (which only had 3.5 framework installed). 1. Create a C# 3.5 web application [&hellip;]<\/p>\n","protected":false},"author":404,"featured_media":58792,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[197],"tags":[7352,7353,7354,7323,7329],"class_list":["post-3254","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-aspnet","tag-package","tag-target-extension","tag-target-file","tag-visual-studio-2010","tag-web-deployment"],"acf":[],"blog_post_summary":"<p>I\u2019ll use a walkthrough example to show how to package a web application with speech API COM component using Visual Studio 2010.&#160; I wrote and tested the sample in Win7 x86 with IIS7.5, and packaged and manually installed to win2k3 x86 IIS6 (which only had 3.5 framework installed). 1. Create a C# 3.5 web application [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/3254","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/users\/404"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/comments?post=3254"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/3254\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media\/58792"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media?parent=3254"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=3254"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=3254"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}