5

I have followed the instruction to get the Template 10 up and running but I am running into a single assembly error CS0234

Error CS0234 The type or namespace name 'ApplicationInsights' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) WindowsApp1 C:\Users\Keshi\AppData\Local\Temporary Projects\WindowsApp1\App.xaml.cs

Any idea's why this assembly is missing. I have installed the entire VS package. Why would this assembly be missing.

        Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync(
        Microsoft.ApplicationInsights.WindowsCollectors.Metadata |
        Microsoft.ApplicationInsights.WindowsCollectors.Session);

Thank you

Jerry Nixon
  • 31,313
  • 14
  • 117
  • 233
user3363744
  • 167
  • 1
  • 9

2 Answers2

5

I had to add a few lines to the project.json file to solve this. I believe the lines I added were (in dependencies):

"Microsoft.ApplicationInsights": "1.0.0", 
"Microsoft.ApplicationInsights.PersistenceChannel": "1.0.0", 
"Microsoft.ApplicationInsights.WindowsApps": "1.0.0", 

My full project.json file looks like:

{
  "dependencies": {
    "Microsoft.ApplicationInsights": "1.0.0", 
    "Microsoft.ApplicationInsights.PersistenceChannel": "1.0.0", 
    "Microsoft.ApplicationInsights.WindowsApps": "1.0.0", 
    "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0", 
    "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0",
    "Microsoft.Xaml.Behaviors.Uwp.Managed": "1.0.3",
    "Newtonsoft.Json": "8.0.2",
    "Template10": "1.1.*"
  },
  "frameworks": {
    "uap10.0": {}
  },
  "runtimes": {
    "win10-arm": {},
    "win10-arm-aot": {},
    "win10-x86": {},
    "win10-x86-aot": {},
    "win10-x64": {},
    "win10-x64-aot": {}
  }
}

And I can build and run the hamburger menu project (it's just the blank template as I'm just getting started).

CodingGorilla
  • 19,612
  • 4
  • 45
  • 65
1

Yes, as of 5/18/2016 Template10 fails to build all of it project types out-of-the-box (Blank, Hamburger, Minimal) for all combinations of UW target/min versions because of the missing reference to application insights.

Direct change to project.json works fine, just as @CodingGorilla suggested.

Alternatively, in VS.Net you can add ApplicationInsights reference to Template10 project using NuGet console or via project drop down menu > Manage NuGet Packages... in the solution explorer.

In NuGet console:

Install-Package Microsoft.ApplicationInsights.WindowsApps

Or

  • Open project's NuGet Manager
  • Switch to the Browse tab
  • Search for Microsoft.ApplicationInsights.WindowsApps
  • Install the package

NuGet will notify you that it installs the target and related packages, e.g.:

    Microsoft.ApplicationInsights.1.2.3 
    Microsoft.ApplicationInsights.PersistenceChannel.1.2.3 
    Microsoft.ApplicationInsights.WindowsApps.1.1.1 

The "dependencies" section in project.json will be changed accordingly:

  "dependencies": {
     "Microsoft.ApplicationInsights.WindowsApps": "1.1.1",
     "Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0",
     "Microsoft.Xaml.Behaviors.Uwp.Managed": "1.1.0",
     "Newtonsoft.Json": "8.0.3",
     "Template10": "1.1.*"
  },
  ...
DK.
  • 3,173
  • 24
  • 33