I'm using a URL parameter as follows in my .razor page
#page "/VehicleBody-CategorizedData"
#page "/VehicleBody-CategorizedData/{PageNumber:int}"
Also, in my index.html page I've following JS tag:
<script src="/_framework/blazor.webassembly.js"></script>
But, when I try to use PageNumber parameter in my page, I get following error
Failed to load resource: the server responded with a status of 404 ()
I've attached console error:
Here is my project configuration:
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseBlazorWebAssembly>true</UseBlazorWebAssembly>
<ValidateExecutableReferencesMatchSelfContained>false</ValidateExecutableReferencesMatchSelfContained>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.1" PrivateAssets="all" />
</ItemGroup>
Related
I want to Use Windows.Gaming.Input (GameInput) in Windows Form project.
I found this link, But I could not add Windows.Gaming.
I have created a project in Microsoft Visual Studio 2022 (.Net 5.0), Then i after created and changed it to .Net Framework 4.8
file .csproj
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net48</TargetFramework>
<TargetPlatformVersion>10.0</TargetPlatformVersion>
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
<UseWpf>False</UseWpf>
<UseWindowsForms>True</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<StartupObject>Service.App</StartupObject>
<PlatformTarget>x64</PlatformTarget>
<Prefer32Bit>False</Prefer32Bit>
<Title>IO Service</Title>
<Description>Assembly providing.</Description>
<RootNamespace>Service</RootNamespace>
<AssemblyTitle>Service</AssemblyTitle>
<AssemblyName>Service</AssemblyName>
<LangVersion>10.0</LangVersion>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<UserSecretsId>e6074671-c86e-45e7-9fe9-7081c2cae035</UserSecretsId>
<Optimize>False</Optimize>
<FileAlignment>512</FileAlignment>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<ApplicationManifest>app.manifest</ApplicationManifest>
<ApplicationIcon>Resources\Icon\App.ico</ApplicationIcon>
<UseApplicationTrust>False</UseApplicationTrust>
<!-- for .Net -->
<ApplicationVisualStyles>True</ApplicationVisualStyles>
<ApplicationHighDpiMode>SystemAware</ApplicationHighDpiMode>
<ApplicationUseCompatibleTextRendering>False</ApplicationUseCompatibleTextRendering>
<ApplicationDefaultFont>Microsoft Sans Serif, 8.25pt</ApplicationDefaultFont>
<AutoGenerateBindingRedirects>False</AutoGenerateBindingRedirects>
<UseVSHostingProcess>False</UseVSHostingProcess>
<ErrorReport>none</ErrorReport>
<WarningLevel>4</WarningLevel>
<Deterministic>True</Deterministic>
<DebugType>portable</DebugType>
<NeutralLanguage>en-US</NeutralLanguage>
<IsWebBootstrapper>False</IsWebBootstrapper>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Runtime.WindowsRuntime" Version="4.7.0" />
</ItemGroup>
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Using Include="Windows.Gaming" />
</ItemGroup>
</Project>
I installed System.Runtime.WindowsRuntime, but Universal Windows was not added in the reference.
image1
image2
after add <TargetPlatformVersion>10.0</TargetPlatformVersion> Global Usings show in project Properties, I added Windows.Gaming in Global Usings but it doesn't work.
image3
image4
Does anyone know what I should do?
I currently training on how to Specflow with C#. I made a few changes to my test saved them. I then performed a 'clean' at project level and got the following error message.
Severity Code Description Project File Line Suppression State
Warning Test assembly not found. Please build the project to enable the SpecFlow Visual Studio Extension features.
0
and this
Severity Code Description Project File Line Suppression State
Error IDE1100 Error reading content of source file 'C:\Users\myname\source\repos\UdemyTrainingProject\UdemyTrainingProject\obj\Debug\net6.0\UdemyTrainingProject.AssemblyInfo.cs' -- 'Could not find file 'C:\Users\myname\source\repos\UdemyTrainingProject\UdemyTrainingProject\obj\Debug\net6.0\UdemyTrainingProject.AssemblyInfo.cs'.'. UdemyTrainingProject C:\Users\myname\source\repos\UdemyTrainingProject\UdemyTrainingProject\obj\Debug\net6.0\UdemyTrainingProject.AssemblyInfo.cs 1 Active
Csprog file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="NUnit.Analyzers" Version="3.3.0" />
<PackageReference Include="coverlet.collector" Version="3.1.2" />
<PackageReference Include="Selenium.Firefox.WebDriver" Version="0.27.0" />
<PackageReference Include="Selenium.Support" Version="4.4.0" />
<PackageReference Include="Selenium.WebDriver" Version="4.4.0" />
<PackageReference Include="Selenium.WebDriver.ChromeDriver" Version="105.0.5195.5200" />
<PackageReference Include="Selenium.WebDriver.MicrosoftDriver" Version="17.17134.0" />
<PackageReference Include="SpecFlow" Version="3.9.74" />
<PackageReference Include="SpecFlow.NUnit" Version="3.9.74" />
<PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.9.74" />
</ItemGroup>
<ItemGroup>
<Folder Include="Features\" />
<Folder Include="Utilities\" />
</ItemGroup>
<ItemGroup>
please watch this video
So I was able to resolve the issue.
Go to the top menu > select project> Build> build solution
the build is successful go to step 3
The Go into the search box with the spy glass logo and type 'test explorer'
In test explorer you have the choice of 2 ways to run:
the small green triangle will run ALL tests
the large green triangle will your chosen test only.
Select from option 4 and run your test.
I create a new page, e.g. in Pages/Clients/ subfolder with following code:
#page "/clients"
#inject NavigationManager NavigationManager
<div>My clients page</div>
I put the link:
<NavLink href="/clients" class="nav-link">Clients</NavLink>
When I click on link the page shows me default message
Sorry, there's nothing at this address.
Then I stop the app. Put my clients page in "Pages" folder. Run the application and I see the proper page with
My clients page
Ok, then I move my page file again to Pages/Clients/ subfolder, run the app and... it still works! Moreover - If I do any changes to Clients.razor page it is being shown correctly in browser.
So it looks like Blazor cannot find the page in subfolder for the first time, but after it "registers" it somehow it could find and show it correctly all the time.
I have the
<base href="~/" />
line in my _Host.cshtml file
Well, I was fighting with it for a couple of days and right after posting on Stackoverflow I accidentally found an answer.
In your .csproj file there were following lines:
<ItemGroup>
<Watch Include="**\*.razor" />
</ItemGroup>
<ItemGroup>
<Content Remove="Pages\Activities\ActivitiesList.razor" />
<Content Remove="Pages\Entrance\Entrance.razor" />
<Content Remove="Pages\Instructors\InstructorsList.razor" />
<Content Remove="Pages\Plan\Plan.razor" />
</ItemGroup>
<ItemGroup>
<None Include="Pages\Activities\ActivitiesList.razor" />
<None Include="Pages\Administration\Administration.razor" />
<None Include="Pages\Entrance\Entrance.razor" />
<None Include="Pages\Instructors\InstructorsList.razor" />
<None Include="Pages\Plan\Plan.razor" />
</ItemGroup>
<ItemGroup>
<Watch Remove="Pages\Activities\ActivitiesList.razor" />
<Watch Remove="Pages\Administration\Administration.razor" />
<Watch Remove="Pages\Entrance\Entrance.razor" />
<Watch Remove="Pages\Instructors\InstructorsList.razor" />
<Watch Remove="Pages\Plan\Plan.razor" />
</ItemGroup>
I removed most of them and left only this:
<ItemGroup>
<Watch Include="**\*.razor" />
</ItemGroup>
All the files are being now discovered correctly. Just remember to check your csproj if some garbage aren't being generated there during development process.
I am trying to understand the contents of a .csproj file after I converted from PCL to a .NET shared. Here is an example and some questions:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="3.1.0.583944" />
<PackageReference Include="sqlite-net-pcl" Version="1.4.118" />
<PackageReference Include="Syncfusion.Xamarin.SfChart" Version="16.2.0.42" />
</ItemGroup>
<ItemGroup>
<Folder Include="Views\" />
<Folder Include="Views\Settings\Pages\" />
<Folder Include="Views\Home\PopUp\" />
<Folder Include="Views\Help\Cards\" />
</ItemGroup>
Can someone explain to me why only certain folders appear above even though my project has many more folders
<ItemGroup>
<EmbeddedResource Remove="Views\Cards\Category\CategoriesPage.xaml" />
<EmbeddedResource Remove="Views\Cards\Templates\LinkTextCell.xaml" />
<EmbeddedResource Remove="Views\Cards\Templates\SwitchViewCell.xaml" />
<EmbeddedResource Remove="Views\Home\Dictionary.xaml" />
</ItemGroup>
Can someone explain what all these Remove lines do / mean?
<ItemGroup>
<None Include="Views\Cards\Cards.xaml" />
<None Include="Views\Cards\Category\CategoriesPage.xaml" />
<None Include="Views\Cards\Category\CategoryViewCell.xaml" />
<None Include="Views\Cards\Templates\LinkTextCell.xaml" />
<None Include="Views\Cards\Templates\SwitchViewCell.xaml" />
<None Include="Views\MainPage.xaml" />
<None Include="Views\MainPage.xaml" />
<None Include="Views\MainPage.xaml" />
<None Include="Views\MainPage.xaml" />
</ItemGroup>
Can someone explain why the MainPage might appear four times? Is it needed more than once, is it needed at all? There are many files that are not in the list of Includes? If only half are there then why is it?
<ItemGroup>
<Compile Update="Views\MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon>
</Compile>
<Compile Update="Views\Home\HomePage.xaml.cs">
<DependentUpon>HomePage.xaml</DependentUpon>
</Compile>
<Compile Update="Views\Cards\Category\CategoryViewCell.xaml.cs">
<DependentUpon>CategoryViewCell.xaml</DependentUpon>
</Compile>
</ItemGroup>
</Project>
I understand that some views depend on others but I have many more of these and yet it only shows the relationship for three. Why could this be?
Can I just remove all these entries from the project file as there seems to be not much similarity between the project file and the folders / files in the project?
The new .csproj format has some basic changes to simplify the file. Now by default all .cs (or .vb if you're doing VB.Net) files are included. See here for more information.
The reason your file is explicitly including some files and folders is because you've probably edited the file properties at some point.
The Remove lines are there to allow files to be part of your project structure but not compiled or embedded automatically.
As for why MainPage.xaml appears multiple times, I have no idea. Either a bug in Visual Studio has added them, or perhaps a source control merge conflict. Either way, those duplicate lines are redundant and can be removed.
In an existing C# WPF solution I can see the app.config and app.release.config files are combined in a folder like structure:
However in my new solution I cannot duplicate this functionality and get this instead:
This is clearly less appealing and takes up a lot of space in the solution explorer. How can I combine my config files to have a folder-like structure?
*note:
I posted this Q/A because I was unable to find anything regarding this issue until I already had the solution and knew exactly what to search for.. After that I found a few similar questions like this one: In Visual Studio (2008) is there a way to have a custom dependent file on another custom file?. Hopefully this helps someone else find the answer quicker than I did.
After lots of file comparisons I found the key in the project file (ProjectName.csproj). To achieve the desired structure you have to make the child configs dependant on the original. Similar to how views have dependant code files.
Change:
<ItemGroup>
<None Include="App.config">
<SubType>Designer</SubType>
</None>
<None Include="App.Production.config" />
<None Include="App.DR.config" />
<None Include="App.INTLiberty.config" />
<None Include="App.Release.config" />
<None Include="App.UAT.config" />
<None Include="App.Training.config" />
<None Include="App.QAProd.config" />
<None Include="App.INTOvation.config" />
<None Include="App.QA.config" />
<None Include="App.QAEnv3.config" />
<None Include="App.QAEnv2.config" />
<None Include="App.QAEnv1.config" />
<None Include="App.Development.config" />
<None Include="App.Debug.config" />
</ItemGroup>
To:
<ItemGroup>
<None Include="App.Production.config" >
<DependentUpon>App.config</DependentUpon>
</None>
<None Include="App.DR.config" >
<DependentUpon>App.config</DependentUpon>
</None>
<None Include="App.INTLiberty.config" >
<DependentUpon>App.config</DependentUpon>
</None>
<None Include="App.Release.config" >
<DependentUpon>App.config</DependentUpon>
</None>
<None Include="App.UAT.config" >
<DependentUpon>App.config</DependentUpon>
</None>
<None Include="App.Training.config" >
<DependentUpon>App.config</DependentUpon>
</None>
<None Include="App.QAProd.config" >
<DependentUpon>App.config</DependentUpon>
</None>
<None Include="App.INTOvation.config" >
<DependentUpon>App.config</DependentUpon>
</None>
<None Include="App.QA.config" >
<DependentUpon>App.config</DependentUpon>
</None>
<None Include="App.QAEnv3.config" >
<DependentUpon>App.config</DependentUpon>
</None>
<None Include="App.QAEnv2.config" >
<DependentUpon>App.config</DependentUpon>
</None>
<None Include="App.QAEnv1.config" >
<DependentUpon>App.config</DependentUpon>
</None>
<None Include="App.Development.config" >
<DependentUpon>App.config</DependentUpon>
</None>
<None Include="App.Debug.config" >
<DependentUpon>App.config</DependentUpon>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
I agree with the easiest solution (editing project file) by RyanS to solve this problem. Sometime back I went through similar situation and solved like this. Hope this helps someone.
1) We can easily add transformation configs to web.config just by clicking "Add Config Transform" menu item.
This will add only number of solution configurations available. If you want to add more transformation configs then you need to add new configurations first. In this below case it will create only two transformations (Debug & Release)
2) Coming to App.config, one will not see this "Add Transform" menu item. Install SlowCheetah plugin and that will add this menu item and then follow step 1.