locked
Hello World VB in VS 2010 RRS feed

  • Question

  • I recently went to VS 2010. When I loaded my Hello World VB app in VS 2010 it went through the conversion process and everything seemed find. The application compiles and shells out to HV as expected. However, basic code straight from the example no longer returns data.

    In the second chunk of code "Dim filter As HealthRecordFilter = New HealthRecordFilter(typeID)", filter is Nothing. Should I go back to 2008?

     

    <code>

            Dim basicItem As Basic = GetSingleValue(Of Basic)(Basic.TypeId)
            If basicItem IsNot Nothing And basicItem.BirthYear.HasValue Then
                c_BirthYear.Text = basicItem.BirthYear.ToString()
            End If
    <code>

    <code>

    Private Function GetSingleValue(Of T As Class)(ByVal typeID As Guid) As T
            Dim searcher As HealthRecordSearcher = Me.PersonInfo.SelectedRecord.CreateSearcher()

            Dim filter As HealthRecordFilter = New HealthRecordFilter(typeID)
            searcher.Filters.Add(filter)

            Dim items As HealthRecordItemCollection = searcher.GetMatchingItems(0)

            If items IsNot Nothing And items.Count > 0 Then
                Return TryCast(items(0), T)
            Else
                Return Nothing
            End If
        End Function
    </code?

    Monday, November 15, 2010 11:47 PM

Answers

  • Hello Grex ,

    I would like to make things clearer for you to run Helloword sample application. I think you have installed the latest version of HealthVault SDK from this location .

    Before running the HelloWorldInVBCertStore sample application from this location "C:\Program Files\Microsoft HealthVault\SDK\DotNet\WebSamples\HelloWorldInVBCertStore"  please make sure that you follow the below steps.

    To install a sample application certificate using the HealthVault Application Manager:

    ·         Browse to C:\Program Files\Microsoft HealthVault\SDK\Tools, and then double-click ApplicationManager.exe by Run as administrator.

    ·         In the Application Manager, Click on the Import Pfx button.

    ·         Browse the .pfx file in the cert folder of the application at :

    ·         “C:\Program Files\Microsoft HealthVault\SDK\DotNet\WebSamples\HelloWorldInVBCertStore\cert\HelloWorld-SDK_ID-05a059c9-c309-46af-9b86-b06d42510550.pfx”.

    ·         Click on Open.

    ·         Right click on the certificate that we have imported and click on Grant access to IIS process.

    ·         The certificate now appears in the Application Manager Certificate list.

    After you install the certificate in your machine please follow the below steps:

    ·         Open the solution (.sln) file from this location “C:\Program Files\Microsoft HealthVault\SDK\DotNet\WebSamples\HelloWorldInVBCertStore”.

    ·         Open the Web.config file and check the below entry present or not

    ·         <add key="ApplicationId" value="05a059c9-c309-46af-9b86-b06d42510550"/>. 

    Now run the application and let me know if you face any issues.

    You can find useful post here.  

    If you are trying to run the your old application then you need to remove HealthVault dll references in your application and add the new HealthVault dll references from this location “C:\Program Files\Microsoft HealthVault\SDK\DotNet\Assemblies”

     Microsoft.Health.dll, Microsoft.Health.ItemTypes.dll and Microsoft.Health.Web.dll

     Hope this helps and let me know if you have any issues.

    Regards,

    Madan Kamuju

    • Proposed as answer by Madan kamuju Thursday, November 25, 2010 10:30 AM
    • Marked as answer by Aneesh D Wednesday, January 12, 2011 2:31 AM
    Friday, November 19, 2010 10:25 AM

All replies

  • Hello Grex,

    I am able to run the sample HelloWorldInVBCertStore application in Visual Studio 2010 without having any issues and also GetSingleValue() method returning the value.  Could you please make sure that you are opening the solution run as administrator.

    Could you please unzip the HealthVaultDLLSource folder from this path "C:\Program Files\Microsoft HealthVault\SDK\Source\HealthVaultDLLSource" because when you try to debug the application.

    Hope this helps and let me know if you face any issues.

    Regards,

    Madan Kamuju

     

     

    Tuesday, November 16, 2010 10:02 AM
  • "Could you please unzip the HealthVaultDLLSource folder from this path "C:\Program Files\Microsoft HealthVault\SDK\Source\HealthVaultDLLSource" because when you try to debug the application"

     

    This is the same thing you had me do a few weeks back when I suddenly was unable to to step through and debug code in my VS 2008 application. After days of getting no where I eventually had to dump the whole project and start over.

    The other thing I noticed with this VS 2010 application is that when I was trying to figure out what was going on with filter = Nothing, when I step through the code with F8 I am taken in to C# code in HealthRecordAccessor.cs. This never happened with VS 2008. My first thought was, "Ok, this is odd, but this is my first VS 2010 app, so...."

    Is there some major problem with my HV SDK installation or are these kinds of issues common? Should I dump everything and start over?

     

    Greg

    Tuesday, November 16, 2010 4:25 PM
  • I *think* the behavior you are seeing is due to the way that versioning works in HealthVault (see post for more details). My guess is that while you are asking for Basic, the platform is returning you BasicV2 (the newer version) instead. This behavior, while expected, is confusing and we did some changes in our most recent SDK (IIRC) that would give you the version you asked for, instead. If that's not working it would be good to know.

    Anyway, if the platform is returning a BasicV2 to you, the TryCast will be unable to convert that to Basic and will therefore return a null value instead. I'd recommend replacing the TryCast with DirectCast, which would then cause an exception if I'm correct.

    The fix would be to change Basic.TypeId to BasicV2.TypeId.

    If you are using the newest SDK assemblies I'd like to know because the new behavior should work with your current code.

    Hope that helps

     

    Tuesday, November 16, 2010 5:19 PM
  • {SIGH!}

     

    This is very demoralizing. I read the article and tried basicV2 with no luck. I blew away the HealthVaultSDK, downloaded a fresh version released 10/13/2010. My original project still had the same problems.

     

    I created a new HelloWorld project and now it throws an exception some place in  EasyWebRequest.cs file.

     

    When I first run the project it tries to locate this file at e:\src\hsg-hv-main\private\hv\prod\src\sdk\core\EasyWebRequest.cs. This is the same thing the other version of the SDK did. I have no idea where it gets this path from. I don't have and E drive, either mapped or local.

     

    I browse to the SDK on my C drive and select the EasyWebRequest.cs and I get another error that says 'The Source file is different from when the module was built would you like to use it anyway. I say yes and it throws and exception. I say no and it weights from me to find the right file.

     

    I try rebuilding the project and every time I start it it tells me it can't find the file on my E drive and I must browse C drive. Again I'm asked the question and again it throws the exception on...

     

                    if (_asyncException != null)
                    {
                        throw _asyncException;
                    }

     

    While and I debugging C# code in a VB.net app in the first place?

    I have no idea what it is asking me for. All of this is the default stuff that comes with the SDK. I'm not making any changes to it. The worst part is, I can't even go back to VS 2008 now if I wanted to. The HealthVault Application Manager makes VS 2010 solution files now.

     

    This has gone from bad to worse....

     

    Greg

     

    Friday, November 19, 2010 12:55 AM
  • Hello Grex ,

    I would like to make things clearer for you to run Helloword sample application. I think you have installed the latest version of HealthVault SDK from this location .

    Before running the HelloWorldInVBCertStore sample application from this location "C:\Program Files\Microsoft HealthVault\SDK\DotNet\WebSamples\HelloWorldInVBCertStore"  please make sure that you follow the below steps.

    To install a sample application certificate using the HealthVault Application Manager:

    ·         Browse to C:\Program Files\Microsoft HealthVault\SDK\Tools, and then double-click ApplicationManager.exe by Run as administrator.

    ·         In the Application Manager, Click on the Import Pfx button.

    ·         Browse the .pfx file in the cert folder of the application at :

    ·         “C:\Program Files\Microsoft HealthVault\SDK\DotNet\WebSamples\HelloWorldInVBCertStore\cert\HelloWorld-SDK_ID-05a059c9-c309-46af-9b86-b06d42510550.pfx”.

    ·         Click on Open.

    ·         Right click on the certificate that we have imported and click on Grant access to IIS process.

    ·         The certificate now appears in the Application Manager Certificate list.

    After you install the certificate in your machine please follow the below steps:

    ·         Open the solution (.sln) file from this location “C:\Program Files\Microsoft HealthVault\SDK\DotNet\WebSamples\HelloWorldInVBCertStore”.

    ·         Open the Web.config file and check the below entry present or not

    ·         <add key="ApplicationId" value="05a059c9-c309-46af-9b86-b06d42510550"/>. 

    Now run the application and let me know if you face any issues.

    You can find useful post here.  

    If you are trying to run the your old application then you need to remove HealthVault dll references in your application and add the new HealthVault dll references from this location “C:\Program Files\Microsoft HealthVault\SDK\DotNet\Assemblies”

     Microsoft.Health.dll, Microsoft.Health.ItemTypes.dll and Microsoft.Health.Web.dll

     Hope this helps and let me know if you have any issues.

    Regards,

    Madan Kamuju

    • Proposed as answer by Madan kamuju Thursday, November 25, 2010 10:30 AM
    • Marked as answer by Aneesh D Wednesday, January 12, 2011 2:31 AM
    Friday, November 19, 2010 10:25 AM
  • Sorry about the problems you are having. I'll try to explain what I can and (with any luck) help you move foreward. If you're still hitting issues you can reach me through email at ericgu at microsoft.com.

    A bit of explanation might make things more clear:

    Debugging in Visual Studio is set up to try to work with all the source on one machine, so there's a hardcoded filename baked into the debug information so it knows where to start. In this case, that long "e:/..." path is the location where the file was on one of the Microsoft build machines. Navigating to the source you have is the right thing to do, but since you installed a new version of the SDK my guess is that you didn't unzip the source for that SDK and instead pointed to the source from the last SDK. That's why the debugger gave you the message about source not matching.

    If you can tell us the text of the exception that you are hitting, that will help narrow it down. I think Madan is on the right track that it is likely to be a certificate issue.

    Friday, November 19, 2010 5:16 PM
  • Ok, the apologies are mine. Following Madan's advice got me up and running again. I now recall doing this months ago when I first started playing around with the HV samples. I'm not sure what went wrong.

    Part of my problem with this is that I only work on this project once every other month, if I'm lucky. I work for a local independent practice association and we aren't really using the HV for anything right now, but it seems like it could be a valuable tool for some projects that require collaboration. I'm trying to familiarize myself with it so if it comes up at a meeting I can talk authoritatively on it.

    I don't normally write web apps and letting it sit idle for 2 or 3 months at a time makes it especially difficult. Thanks for your help.

    Greg

     

     

     

    Friday, November 19, 2010 7:30 PM