Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Access Denied" with latest Phi Silica capabilities with 1.7 experimental 3 #5115

Open
StevenBucher98 opened this issue Feb 7, 2025 · 8 comments
Assignees
Labels
area-WCR documentation Improvements or additions to documentation
Milestone

Comments

@StevenBucher98
Copy link

Describe the bug

I have been having some trouble getting the new phi silica SDK capabilities working on the experiment 3 release. For one I had to add <WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained> to my csproj file in order for the program to fine the registered files so I suggest adding details on adding this in the instructions in the docs.

My main issue now is with some weird "Access Denied" bug when I try to run the simple console app example.

Image

Steps to reproduce the bug

In VSCode try the following code given all necessary pre-reqs in the doc and try running it.

using Microsoft.Windows.AI.Generative;

if (!LanguageModel.IsAvailable())
{
    var op = LanguageModel.MakeAvailableAsync().GetResults();
}

using LanguageModel languageModel = LanguageModel.CreateAsync().GetResults();

string prompt = "Provide the molecular formula for glucose.";

var result = languageModel.GenerateResponseAsync(prompt).GetResults();

Console.WriteLine(result.Response);

Expected behavior

The molecular formula for glucose is C6H12O6.

Screenshots

Image

NuGet package version

Windows App SDK 1.7 Experimental 3: 1.7.250127003-experimental3

Packaging type

Unpackaged

Windows version

Windows 11 version 24H2 (22621, October 2024 Update)

IDE

Visual Studio 2022

Additional context

I am not sure if this is packaged or unpackaged

@RDMacLachlan RDMacLachlan added area-WCR documentation Improvements or additions to documentation labels Feb 7, 2025
@eduhrami
Copy link

eduhrami commented Feb 7, 2025

If the app is not packaged it will not work. You can check if your app is a package in the debug button.

Image

@connorMicrosoft
Copy link

Hey Steven,

Thanks for trying this out!

There are two issues here:

  1. You're trying to use self-contained mode, which we don't currently support. We'll get our release notes updates to make this more clear.
  2. You're trying to use .GetResults() incorrectly. The docs are correct - they use await instead. There is additional work if you want to use GetResults() . You can use await keyword for async function or .GetAwaiter().GetResult() instead for a similar result.

@StevenBucher98
Copy link
Author

StevenBucher98 commented Feb 7, 2025

Thank you both! If I don't include the <WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained> in the csproj then I get this following error

Image

I changed back to use await like in the docs.

My debug button looks like this

Image

@eduhrami does this mean its unpackaged? and if so how do I package it?

@eduhrami
Copy link

Hey @StevenBucher98 , sorry the late reply. The easiest way to get a packaged app would be to create your project using the "Blank App, Packaged Win UI" template from the Create New Project Wizard.

Image

@pratikone
Copy link
Contributor

pratikone commented Feb 12, 2025

Thanks for reporting this @StevenBucher98
WCR apis will work with packaged as well as unpackaged apps.
I followed your instructions and found the issue too.
Turns out a C# console app due to some issue, doesn't define itself as packaged or unpackaged. This confuses WCR apis and they don't work. I will file a bug internally.

As for a workaround, you can explicitly mentiond
<WindowsPackageType>None</WindowsPackageType> in your .csproj of the project and WCR apis should start working.This will define your app as unpackaged.

I am using the following snippet . You can use something similar or the await instructions from the docs.

if (!LanguageModel.IsAvailable())
{
    var op = LanguageModel.MakeAvailableAsync().GetAwaiter().GetResult();
}

using LanguageModel languageModel = LanguageModel.CreateAsync().GetResults();
string prompt = "Provide the molecular formula for glucose.";

var result = languageModel.GenerateResponseAsync(prompt).GetAwaiter().GetResult();
Console.WriteLine(result.Response);
`

@daxian-dbw
Copy link
Member

@pratikone This is great to know! Thank you!

The documentation says "Unpackaged apps are currently unsupported", so will it suddenly stops working for an unpackaged app (regular console app) at some point?

Image

@pratikone
Copy link
Contributor

pratikone commented Feb 12, 2025

That is definitely a mistake. Self-contained are currently unsupported. We will get the docs fixed. Thanks for reporting.
Unpackaged apps are supported. They require installing winappruntime explicitly from the installer (https://learn.microsoft.com/en-us/windows/apps/windows-app-sdk/downloads)

Edit : It is fixed in docs https://learn.microsoft.com/en-us/windows/ai/apis/

@daxian-dbw
Copy link
Member

@pratikone That's great to know. Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-WCR documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

7 participants