Menu

Wanted to let you know

2008-04-14
2013-03-25
  • Chris Holland

    Chris Holland - 2008-04-14

    I've built a project file for the code and made a test configuration to get this running. Everything looks good except for some reason my computer doesn't want to generate the audio wav for some reason. They all come out 1k.

    Anyway if anyone else is looking for info on how to get this running, here is my example.

    Here is the relevant stuff to put in your main site's webconfig:

    -- goes under <configuration>
      <configSections>
        <sectionGroup name="DevGhoul.Controls.WebControls">
          <section name="CaptchaDotNet"
                    type="CaptchaDotNetObjects.Configuration.ConfigurationSection, CaptchaDotNetObjects"
                />
        </sectionGroup>
      </configSections>

    -- goes under <system.web>

          <httpHandlers>
            <add verb="GET" path="captcha.cap" type="CaptchaDotNetObjects.HttpHandlers.ImageHandler"/>
            <add verb="GET" path="captcha.capa" type="CaptchaDotNetObjects.HttpHandlers.SpeakTextHandler"/>
          </httpHandlers>

    -- goes before the </configuration> tag

      <DevGhoul.Controls.WebControls>
        <CaptchaDotNet defaultProvider="CaptchaDotNetObjects.DefaultCaptchaProvider, CaptchaDotNetObjects" debug="false">
          <httpHandlers>
            <add type="ImageHandler"  path="captcha.cap" />
            <add type="AudioHandler"  path="captcha.capa" />
          </httpHandlers>
        </CaptchaDotNet>
      </DevGhoul.Controls.WebControls>

    Here is my project file for it:

    <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
        <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
        <ProductVersion>8.0.50727</ProductVersion>
        <SchemaVersion>2.0</SchemaVersion>
        <ProjectGuid>{E574846B-3A0A-4235-B28D-DFB3F8CC47FE}</ProjectGuid>
        <OutputType>Library</OutputType>
        <AppDesignerFolder>Properties</AppDesignerFolder>
        <RootNamespace>CaptchaDotNetObjects</RootNamespace>
        <AssemblyName>CaptchaDotNetObjects</AssemblyName>
      </PropertyGroup>
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
        <DebugSymbols>true</DebugSymbols>
        <DebugType>full</DebugType>
        <Optimize>false</Optimize>
        <OutputPath>bin\Debug\&lt;/OutputPath>
        <DefineConstants>DEBUG;TRACE</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
      </PropertyGroup>
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
        <DebugType>pdbonly</DebugType>
        <Optimize>true</Optimize>
        <OutputPath>bin\Release\&lt;/OutputPath>
        <DefineConstants>TRACE</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
      </PropertyGroup>
      <ItemGroup>
        <Reference Include="System" />
        <Reference Include="System.configuration" />
        <Reference Include="System.Data" />
        <Reference Include="System.Design" />
        <Reference Include="System.Drawing" />
        <Reference Include="System.Web" />
        <Reference Include="System.Xml" />
      </ItemGroup>
      <ItemGroup>
        <Compile Include="AssemblyPermissions.cs" />
        <Compile Include="Configuration\Config.cs" />
        <Compile Include="Configuration\ConfigurationSection.cs" />
        <Compile Include="Control\Control.cs" />
        <Compile Include="Control\Customize.cs" />
        <Compile Include="Control\Designer.cs" />
        <Compile Include="DefaultCaptchaProvider.cs" />
        <Compile Include="Handlers\AudioHandler.cs" />
        <Compile Include="Handlers\ImageHandler.cs" />
        <Compile Include="Interfaces\ICaptchaProvider.cs" />
        <Compile Include="Properties\AssemblyInfo.cs" />
        <Compile Include="Resource.Designer.cs" />
        <Compile Include="Security\Cryptography\Encryptor.cs" />
        <Compile Include="Security\Cryptography\RandomText.cs" />
        <Compile Include="Security\Cryptography\RNG.cs" />
      </ItemGroup>
      <ItemGroup>
        <EmbeddedResource Include="Resource.resx">
          <SubType>Designer</SubType>
        </EmbeddedResource>
      </ItemGroup>
      <ItemGroup>
        <COMReference Include="SpeechLib">
          <Guid>{C866CA3A-32F7-11D2-9602-00C04F8EE628}</Guid>
          <VersionMajor>5</VersionMajor>
          <VersionMinor>0</VersionMinor>
          <Lcid>0</Lcid>
          <WrapperTool>tlbimp</WrapperTool>
          <Isolated>False</Isolated>
        </COMReference>
      </ItemGroup>
      <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
      <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
           Other similar extension points exist, see Microsoft.Common.targets.
      <Target Name="BeforeBuild">
      </Target>
      <Target Name="AfterBuild">
      </Target>
      -->
    </Project>

     
    • Ziros

      Ziros - 2008-04-15

      hi,
      maybe the path you saving the wav file need a permission ?

      anyway I would gratefull if you can email me the captcha.net project and files
      I'm pulling my hair making it run here and it's kind of urgent.

      again thanks in advance.

       
      • Chris Holland

        Chris Holland - 2008-04-15

        Sure I'll also put it up here: http://www.wickwack.com/captchadotnet/Captcha.zip

        In the zip is a project file for all the lib code. In the CaptchaTest folder is a project and solution file that has a simple webpage using it, and the web.config file.

         
    • Ziros

      Ziros - 2008-04-15

      First of all thanks for the super quick reply
      I'll test it and let you knowhow its going !

       
    • Ziros

      Ziros - 2008-04-15

      Hi cholland

      I managed to set the captcha project, and set the CaptchaTest web app.

      couple of problems I do have... [even when I compile the solution and all succeeded]

      1) when I look at the Default.aspx at design view I see the captcha_test control
         but it says on the control:

         Error Creating control - captcha_test
         Exception has been thrown by the target of an invocation 

      2) even though I was able to run the app and saw the captcha image,
         and managed to put the right text which returned that all ok or not according to my typed text
        
         Audio showed without a picture, here is the value from the property on the page
         [http://localhost:2326/captcha.cap?action=image&type=gif&name=accessibility]
       
         while I pushed play the app kicked out

      Do you have the same symptoms ?

      TIA
        

       
    • Chris Holland

      Chris Holland - 2008-04-15

      Heh I never use design view, it annoys me. I assume the exception for design view has to do with how the properties are setup on the control. I get the same error but I'm not sure where exactly to trap it to figure out what is going on. Debugging it didn't help much.

       
    • Ziros

      Ziros - 2008-04-16

      ok thx, I will try to figure it out

      do you have the same audio problem ? Ill try to paste the error caused by pressing the audio link.

       
    • Ziros

      Ziros - 2008-04-16

      Audio Image not showing in page.

      this is the exception I get in ImageHandler.cs

      Bitmap image = (Bitmap)Resource.ResourceManager.GetObject(context.Request.QueryString["name"]);

      {"Could not find any resources appropriate for the specified culture or the neutral culture.
      Make sure \&quot;CaptchaDotNet.Resource.resources\&quot;
      was correctly embedded or linked into assembly \&quot;CaptchaDotNetObjects\&quot; at compile time,
      or that all the satellite assemblies required are loadable and fully signed."}

      any clue ?

       
    • Ziros

      Ziros - 2008-04-27

      Well after trying to figure out resource problem, I created the project from scratch
      and all is well now with the resource file.

      There is still problem though with the play audio button
      while pressing the play audio button the program crashes and browser closes
      cholland did you managed to use the audio ?
      or anyone else ?

       
      • Chris Holland

        Chris Holland - 2008-04-27

        Yes a coworker got it working on his vista machine. It is probably due to the speech com object you use on the server.

         
    • Ziros

      Ziros - 2008-04-27

      thanks... well I'm trying now to publish the test captcha to our webserver
      to test the speech over there.

      I bumped now into another problem....

      while I ran the Test webapp on my machine with (Visual Studio Development webserver) all is going well
      I can see the captch img and the accesibilty icon

      but when publish the test site to our webserver which use IIS (or even at my machine with IIS instead of
      VS Development webserver) Images stops showing , like the handlers not functions....

      the web.config is the same all is the same whats could be wrong ?

      and thanks again for helping me getting through all the problems here :)

       
    • Farshid Hosseini

      Hi everyone.

      The problem with VS designer is a known bug: http://sourceforge.net/tracker/index.php?func=detail&aid=1914124&group_id=220909&atid=1050829

      For your problem with handlers, make sure you are using an extension that is mapped to .NET in IIS. For example, the extensions Chris has used (.cap and .capa) will not work by default.

      Hope this helps.

       
    • Chris Holland

      Chris Holland - 2008-04-27

      Yeah for the handlers to work you need to right click on the webserver root, or each individual site. Go to properties->home directory->configuration add in .cap and .capa use the normal aspnet_isapai.dll that everything else uses, and uncheck Check that file exists.

       
    • Ziros

      Ziros - 2008-04-28

      Thank you both for the help with handlers. handler working both on my machine and the web server.

      Still have a Speech problem...

      1) on my machine while pressing the play button, explorere crashes.
         what com object should I try to replace ?

      2) on the server all looks well, explorer don't crash but wav files in c:\windows\temp creating with size of 1K only
         so no speech while pressing the play.

      Thanks for helping

       
    • Ziros

      Ziros - 2008-04-28

      More specific info about wav created only 1k [server is windows 2003]

      I managed to use remote debugging on the server and this is the exception that happens while pressing the play button:

      The line causeing the exception at DefaultCaptchaProvider.cs :
      Line 206 - speech.Speak(text, SpeechVoiceSpeakFlags.SVSFIsXML);

      [System.UnauthorizedAccessException]
          {"Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"}    System.UnauthorizedAccessException

      Source    "Interop.SpeechLib"    string

      StackTrace    "   at SpeechLib.SpVoiceClass.Speak(String Text, SpeechVoiceSpeakFlags Flags)\r\n   at CaptchaDotNetObjects.DefaultCaptchaProvider.SpeakToFile(String text, FileInfo info) in C:\\Documents and Settings\\ronens.JAZONTDOM\\My Documents\\Visual Studio 2008\\Projects\\CaptchaDotNetObjects\\DefaultCaptchaProvider.cs:line 206\r\n   at CaptchaDotNetObjects.HttpHandlers.SpeakTextHandler.ProcessRequest(HttpContext context) in C:\\Documents and Settings\\ronens.JAZONTDOM\\My Documents\\Visual Studio 2008\\Projects\\CaptchaDotNetObjects\\Handlers\\AudioHandler.cs:line 52"    string

      I tried giving temp directory under windows permission for IUSER,Network Service,AspNet but nothing helped...
      although the file do saved in the directory just with 1k in size...

      in my computer it worked... and files where at about 25k (XP)

       
    • Farshid Hosseini

      I think you need to check SpeechLib documentation. Though the audio files this library generates are easy to hack and we need to find another way to approach audio challenge.

       
    • Ziros

      Ziros - 2008-04-29

      didnt find anything on documantaion...
      any one bumped into this permission issue ?

      what permission do I have to grant NETWORK SERVICE on the 2003 server to make this work ?

       
    • Ziros

      Ziros - 2008-04-29

      ok guys all solved !

      with the help of Process Monitor
      the speech program tried to write i guess a temporary file to:
      c:\Document and Setting\Default User\Application Data\Microsoft\Speech\Files\UserLexicons

      first off all the directory was not complete on the server - so i build all the subdirectories missing
      and granting a permission on the last sub directory and all is ok now !!!

      Thank you all for help

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.