TransformItem "tohv" throwing exception in .Net 4 RRS feed

  • Question

  • I am getting the following exception: The type or namespace name 'SecurityRulesAttribute' does not exist in the namespace 'System.Security' (are you missing an assembly reference?) on the TransformItem method using "tohv". 

    This seems to be related to .Net 4 as we are migrating the code base and it works fine in .Net 3.5.

    Any insight as to what might be going on here would be appreciated.

    Wednesday, April 18, 2012 9:38 PM

All replies

  • Take a look at the following and see if any of these steps work for you.


    Jeff Jones Technical Lead HealthVault Development Team

    Thursday, April 19, 2012 3:03 PM
  • Yes the production server seems to be configured properly.

    The app works fine on a development server with IIS .net 4.

    I assume the SDK is compiled for .Net4? I can't seem to get the latest sdk source to compile on my machine: 

    Error 4 D:\_PROJECTS\_MSNET\HealthVault_Source\Core\ItemTypes\CodableValue.cs 267 Cannot convert type 'Microsoft.Health.ItemTypes.CodedValue' to 'Microsoft.Health.VocabularyItem' via a reference conversion, boxing conversion, unboxing conversion, wrapping conversion, or null type conversion

    Is there anything special I need to be doing to use .net 4?

    Friday, April 20, 2012 1:08 PM
  • The .NET SDK is compiled for .NET 2.0 for a variety of reasons I won't bore you with and is currently the only supported development environment. We're looking at moving it to .NET 4.0 in a future release but there are some things holding us back.

    Jeff Jones Technical Lead HealthVault Development Team

    Friday, April 20, 2012 2:49 PM
  • does that mean my app can't target .net 4 either?
    Friday, April 20, 2012 7:49 PM
  • any other ideas on what I  can check to resolve this issue?

    I am at a loss right now as the server seems to be configured correctly and the app runs fine on a local machine using IIS/.net 4?


    Friday, April 20, 2012 10:54 PM
  • Can you verify that the AppPool your app is running under is .NET 4?  We've seen cases where this error has occurred because the AppPool was still .NET 2.0. I'm still doing some investigation to see if I can get you a better answer.

    Jeff Jones Technical Lead HealthVault Development Team

    Friday, April 20, 2012 11:05 PM
  • Can you try following the instructions at http://msdn.microsoft.com/en-us/library/dd483478.aspx? You probably have clean some compiler elements out of your web.config.

    If that doesn't work, try adding the following to your web.config. Do this as a last resort.



                <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089">

                    <providerOption name="CompilerVersion" value="v4.0"/>

                    <providerOption name="WarnAsError" value="false"/>




    The issue is that the "tohv" XSLT has some embedded C#.  Currently the code gets compiled at runtime using the configured compiler. In .NET 2.0, 3.0 and 3.5 these were often configured in the web.config. So you're probably getting the .NET 3.5 compiler and libraries when the embedded C# gets compiled at runtime.

    Jeff Jones Technical Lead HealthVault Development Team

    Friday, April 20, 2012 11:18 PM
  • thanks Jeff. that did the trick
    Friday, April 20, 2012 11:35 PM
  • Thank you! Finally found solution to this problem :) 
    Thursday, May 3, 2012 5:44 PM