I have a test project under Xamarin that when I try to run it it tells me it can't load System.Core though from the screen shot it is clear that System.Core is one of the references.
What Might be the error here?
(open the image in a new tab to see it in full detail)
It seems the problem is with my primary project not the test project. When
I looked at all the references they were red. So I deleted them and tried
to add them again but there are no references to add. See the image below.
The following edits to the .csproj file fixed the problem
--- a/SketchSolveC#/SketchSolveC#.csproj
+++ b/SketchSolveC#/SketchSolveC#.csproj
## -6,12 +6,9 ##
<ProductVersion>12.0.0</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{46D849FA-8E4B-4656-B494-290697EBD9EC}</ProjectGuid>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<RootNamespace>SketchSolveC</RootNamespace>
<AssemblyName>SketchSolveC#</AssemblyName>
- <TargetFrameworkProfile>Profile1</TargetFrameworkProfile>
- <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
## -30,15 +27,13 ##
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
- <Reference Include="System" />
- <Reference Include="System.Xml" />
- <Reference Include="System.Core" />
- </ItemGroup>
- <ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SketchSolve.cs" />
+ <Reference Include="System.Xml" />
+ <Reference Include="System.Data.Linq" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
</ItemGroup>
- <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<ProjectExtensions>
<MonoDevelop>
<Properties>
## -49,4 +44,4 ##
</Properties>
</MonoDevelop>
</ProjectExtensions>
-</Project>
\ No newline at end of file
+</Project>
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.
This error started occuring when I modified the .csproj contents. But after that i restored the original version. The error still persists, actually with no sensible reason.
/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/xbuild/Microsoft/NuGet/Microsoft.NuGet.targets(5,5): Error: Your project file doesn't list 'win' as a "RuntimeIdentifier". You should add 'win' to the "RuntimeIdentifiers" property in your project file and then re-run NuGet restore.
.csproj file content:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D1B1F4F8-C9CF-4DC4-966D-DD7FF4683A1C}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>...</RootNamespace>
<AssemblyName>...</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<PackOnBuild>true</PackOnBuild>
<PackageId>...</PackageId>
<PackageVersion>0.1</PackageVersion>
<Authors>Mondonno</Authors>
<NeutralLanguage>en-US</NeutralLanguage>
<Owners>...</Owners>
<PackageProjectUrl>...</PackageProjectUrl>
<PackageReleaseNotes>...</PackageReleaseNotes>
<PackageTags>...</PackageTags>
<Title>...</Title>
<Description>...</Description>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Debug\AirlyNet.xml</DocumentationFile>
<ConsolePause>false</ConsolePause>
<LangVersion>9.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<LangVersion>9.0</LangVersion>
</PropertyGroup>
<ItemGroup>
...
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
...
</ItemGroup>
<ItemGroup>
...
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>
I tried to add the RuntimeIdentifier and RuntimeIdentifiers but facing the same error. Rebuilding or refreshing project have not helped.
To solve the problem i deleted obj directory from my solution folder Something was broken in it and when VS regenereted it problem was gone
Thanks to #Matt Ward who suggested this in question comments.
I have the line using System.Deployment.Application; at the beginning of my code. There is a red squiggly line under Application and mousing over it gives me the following information:
The type or namespace name 'Application' does not exist in the namespace 'System.Deployment' (are you missing an assembly reference?) (CS0234)
This of course gives me problems when I use ApplicationDeployment and it says The name 'ApplicationDeployment' does not exist in the current context (CS0103)
Why is Visual Studio telling me that Application is not a part of System.Deployment?
From Visual Studio Code, open your.csproj file. In this file you can add an assembly reference to System.Deployment which should fix you issue.
Reference:
<Reference Include="System.Deployment"/>
This will be added in the ItemGroup Section of the .csproj file
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="System.Deployment"/>
</ItemGroup>
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.