I have defined a context (inherited from DbContext) and in C# I use:
await _context.People.SingleOrDefaultAsync()
But having the context in the F# code, the *Async methods don't exist:
_context.People...
How can I call SingleOrDefaultAsync?
I am using Entity Framework Core.
This is my .fsproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="PeopleQuery.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.4" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Domain.People.csproj" />
</ItemGroup>
</Project>
Related
I have a .NET Standard 2.0 project which is using Serilog assembly to log using serilog, here is project file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyTitle>Logger</AssemblyTitle>
<Description>Client Web Logger</Description>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Win32.Registry" />
<PackageReference Include="SchneiderElectric.Software.SASigning" />
<PackageReference Include="Serilog" />
<PackageReference Include="Serilog.AspNetCore" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="Microsoft.CodeAnalysis.FxCopAnalyzers" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="SET _WWBinDir="$(ProjectDir)..\..\..\interfaces\bin\$(ConfigurationName)\$(PlatformName)"
MKDIR %_WWBinDir%
robocopy "$(TargetDir) " "%_WWBinDir%" InSightLogger.dll /ZB /NJH /NJS /NDL /NFL /NC /NS
:END
exit 0
" />
</Target>
I have two other projects in my solution one is in .NET 6.0 and other one is in NET Framework 4.8
here is project files of .NET 6.0:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup Label="Globals">
<Description>My Server</Description>
<TypeScriptToolsVersion>3.1</TypeScriptToolsVersion>
<TargetFramework>net6.0</TargetFramework>
<_HasReferenceToSystemRuntime>true</_HasReferenceToSystemRuntime>
<RootNamespace>My.Insight</RootNamespace>
<DefineConstants>DESKTOP;LICENSEREQUIRED</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Compile Remove="App_Start\**" />
<Content Remove="App_Start\**" />
<EmbeddedResource Remove="App_Start\**" />
<None Remove="App_Start\**" />
</ItemGroup>
<ItemGroup>
<Folder Include="..\..\Common\wwwroot\Insight" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Favorites\FavoriteApiModel\FavoriteApiModel.csproj" />
<ProjectReference Include="..\..\Logger\Logger\Logger.csproj" />
<ProjectReference Include="..\LicenseUtil\LicenseUtil.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="WWMenuHttpModule" Version="4.0.21100101" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="Microsoft.CodeAnalysis.FxCopAnalyzers" />
</ItemGroup>
And Framework project file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<RootNamespace>my.InSight</RootNamespace>
<TargetFramework>net48</TargetFramework>
<AssemblyTitle>Article Server Service</AssemblyTitle>
<NeutralLanguage>en-US</NeutralLanguage>
<Description>Article Service</Description>
</PropertyGroup>
<Import Project="..\..\..\SharedComponents\External\StyleCop\StyleCop.Targets" />
<ItemGroup>
<PackageReference Include="System.Net.Http" />
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="StyleCop" />
<PackageReference Include="System.Configuration.ConfigurationManager" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Logger\Logger\Logger.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Management" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Configuration.Install" />
</ItemGroup>
<ItemGroup>
<Compile Update="ProjectInstaller.cs">
<SubType>Component</SubType>
</Compile>
<Compile Update="ProjectInstaller.Designer.cs">
<DependentUpon>ProjectInstaller.cs</DependentUpon>
</Compile>
<Compile Update="myService.cs">
<SubType>Component</SubType>
</Compile>
<Compile Update="myService.Designer.cs">
<DependentUpon>myService.cs</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="ProjectInstaller.resx">
<DependentUpon>ProjectInstaller.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Update="myService.resx">
<DependentUpon>myService.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Update="Microsoft.CodeAnalysis.FxCopAnalyzers" />
</ItemGroup>
for .NET 6.0 all thing is working fine but for .NET Framework 4.8 it through exception when I am accessing logger projects static class and method, here is exception I am getting
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable C:\Program Files (x86)\WonderWorld\MyInsight\Server\aahInSightHost.exe
--- A detailed error log follows. --Pre-bind state information --
LOG: DisplayName = netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
Fully-specified)
LOG: Appbase = file:///C:/Program Files (x86)/WonderWorld/MyInsight/Server/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = aahInSightHost.exe
Calling assembly : Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Program Files (x86)\WonderWorld\MyInsight\Server\aahInSightHost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Wonderware/HistorianInsight/Server/netstandard.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Wonderware/HistorianInsight/Server/netstandard/netstandard.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Wonderware/HistorianInsight/Server/netstandard.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Wonderware/HistorianInsight/Server/netstandard/netstandard.EXE.
LOG: All probing URLs attempted and failed.
Note: only one thing I noted that I created netstandard2.0 project and in logs it is mentioned that netstandard 2.1.0.0 is searching for, but could not understand.
By closely investigating your project files I came to know that you are using dotnet standard 2.0 but in error it searches from dotnet standard 2.1 so you need to verify all projects with used package version and use appropriate one.
Have defined multitarget project:
<Project Sdk="MSBuild.Sdk.Extras/2.0.54">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;xamarinios10;monoandroid9.0;</TargetFrameworks>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="4.6.0.800" />
<PackageReference Include="Xamarin.Essentials" Version="1.5.3" />
<Compile Include="**\Shared\*.cs" />
</ItemGroup>
<ItemGroup Condition=" $(TargetFramework.StartsWith('xamarinios')) ">
<Compile Include="**\iOS\*.cs" />
</ItemGroup>
<ItemGroup Condition=" $(TargetFramework.StartsWith('monoandroid')) ">
<Compile Include="**\Android\*.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Shared\MyView.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
</ItemGroup>
</Project>
So, when i make my custom component only in code all compile and works well, but i would like to develop some custom controls using XAML.
But i got error of ambiguous call to method InitializeComponent() in MyView object.
How to make correct conditional configuration in .csproj for compiler to understand *.xaml and *.xaml.cs files ?
Adding these properties to common ItemGroup solved the problem:
<None Remove="**\Shared\*.xaml" />
<Compile Include="**\Shared\*.xaml.cs" DependentUpon="%(Filename)" />
<EmbeddedResource Include="**\Shared\*.xaml" Generator="MSBuild:UpdateDesignTimeXaml" />
I am trying to use https://platform.uno/ to build some tools. The WASM (WebAssembly)-Project from uno-platform template will not start due to FileNotFoundExceptions regarding some base Microsoft libs.
I created a new uno-platform APP from uno template. I have updated all NuGet packages to latest version. When I start the wasm web-project I get the following exceptions (at bootstrap i guess):
followed by:
followed by:
Here you can see the Exception class comes from the namespace that was not found in picture 1. It's very strange to me and I don't know whats up anymore.
I guess this is an issue with prerequisites or wrong versions in dependencies somewhere. Does anybody know whats up?
Here is the csproj of the WASM project:
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netstandard2.0</TargetFramework>
<WasmHead>true</WasmHead>
<DefineConstants>$(DefineConstants);__WASM__</DefineConstants>
<NoWarn>NU1701</NoWarn>
<StartupObject>Macs3.Calculations.TestTool.Wasm.Program</StartupObject>
<MonoRuntimeDebuggerEnabled>true</MonoRuntimeDebuggerEnabled>
</PropertyGroup>
<ItemGroup>
<Content Include="..\Macs3.Calculations.TestTool.UWP\Assets\*.png" Link="Assets\%(FileName)%(Extension)" />
<Content Include="Fonts\winjs-symbols.woff2" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="WasmCSS\Fonts.css" />
<EmbeddedResource Include="WasmScripts\AppManifest.js" />
</ItemGroup>
<ItemGroup>
<LinkerDescriptor Include="LinkerConfig.xml" />
</ItemGroup>
<ItemGroup>
<!--
This item group is required by the project templace because of the
new SDK-Style project, otherwise some files are not aded automatically.
You can safely remove this ItemGroup completely.
-->
<Compile Remove="Program.cs" />
<Compile Include="Program.cs" />
<Content Include="LinkerConfig.xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Uno.UI" Version="1.46.0-dev.2039" />
<PackageReference Include="Uno.Wasm.Bootstrap" Version="1.0.0-dev.298" />
</ItemGroup>
<Import Project="..\Macs3.Calculations.TestTool.Shared\Macs3.Calculations.TestTool.Shared.projitems" Label="Shared" Condition="Exists('..\Macs3.Calculations.TestTool.Shared\Macs3.Calculations.TestTool.Shared.projitems')" />
</Project>
I'm working on creating sample for clean architecture. When I had made core and infrastructure projects there were no problems. No I had add new API project and I got problem, picture bellow
I had tried to add project references in csproj but still have a problem, can anyone help me to fix this problem ?
Here is the link for project: https://github.com/danijel88/Clean-Architecture
Regards,
Danijel
Here's a question similar to yours
Here's a sample .csproj. Be sure to have
<TargetFramework>netcoreapp2.2</TargetFramework>
Make sure your project is on 2.2 before updating your packages to 2.2.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TypeScriptToolsVersion>3.1</TypeScriptToolsVersion>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
<CopyRefAssembliesToPublishDirectory>false</CopyRefAssembliesToPublishDirectory>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Gelf.Extensions.Logging" Version="1.5.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="3.1.2" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.1" />
<PackageReference Include="SlackLogger" Version="2.0.5" />
<PackageReference Include="System.Xml.Linq" Version="3.5.21022.801" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Nozomi.Infra.Preprocessing\Nozomi.Infra.Preprocessing.csproj" />
<ProjectReference Include="..\Nozomi.Infra.Service.Identity\Nozomi.Infra.Service.Identity.csproj" />
<ProjectReference Include="..\Nozomi.Infra.Service\Nozomi.Infra.Service.csproj" />
</ItemGroup>
<ItemGroup>
<_ContentIncludedByDefault Remove="Areas\Identity\Pages\_ViewImports.cshtml" />
</ItemGroup>
</Project>
I am running into a situation. I am trying to use MSBuild batching to copy a folder (subdirectories as well as files) to mutilple dest folders.
but when i run the below script, it dumps every content from the src (contents from sub directories too) in root target directory, whereas what i was looking was to get the exact same structure as in src in the target dirs.
<PropertyGroup>
<Srcfldr>C:\helloworld\REService</Srcfldr>
<DestFldr>C:\Projects\desire\Examples</DestFldr>
</PropertyGroup>
<ItemGroup>
<SrcToCopy Include="$(Srcfldr)\*.*"/>
</ItemGroup>
<ItemGroup>
<DestToCopy Include="$(DestFldr)/destfldr1"/>
<DestToCopy Include="$(DestFldr)/destfldr2"/>
<DestToCopy Include="$(DestFldr)/destfldr3"/>
</ItemGroup>
<Target Name="DeployBatching">
<RemoveDir Directories="#(DestToCopy)"/>
<MakeDir Directories="#(DestToCopy)"/>
<Copy SourceFiles="#(SrcToCopy)" DestinationFolder="%(DestToCopy.FullPath)" />
Can you please tell me what am i doing wrong ...
SK
Vanilla copy task is better suited for copying files rather than directories, in any case to preserve structure you need to remap destination using %(RecursiveDir) and %(Filename)%(Extension) metadata. See second example on MSDN.
Edit:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Srcfldr>C:\helloworld\REService</Srcfldr>
<DestFldr>C:\Projects\desire\Examples</DestFldr>
</PropertyGroup>
<ItemGroup>
<SrcToCopy Include="$(Srcfldr)\**\*"/>
</ItemGroup>
<ItemGroup>
<DestToCopy Include="$(DestFldr)\destfldr1"/>
<DestToCopy Include="$(DestFldr)\destfldr2"/>
<DestToCopy Include="$(DestFldr)\destfldr3"/>
</ItemGroup>
<Target Name="DeployBatching" Outputs="%(DestToCopy.FullPath)">
<PropertyGroup>
<DestToCopy>%(DestToCopy.FullPath)</DestToCopy>
</PropertyGroup>
<RemoveDir Directories="#(DestToCopy)"/>
<MakeDir Directories="#(DestToCopy)"/>
<Copy
SourceFiles="#(SrcToCopy)"
DestinationFiles="#(SrcToCopy->'$(DestToCopy)\%(RecursiveDir)\%(Filename)%(Extension)')"
/>
</Target>
</Project>
Doesn't look like it's working the way i wanted it to ... I tried the below code
<PropertyGroup>
<Srcfldr>C:\helloworld\REService</Srcfldr>
<DestFldr>C:\Projects\desire\Examples</DestFldr>
</PropertyGroup>
<ItemGroup>
<SrcToCopy Include="$(Srcfldr)\*.*"/>
</ItemGroup>
<ItemGroup>
<DestToCopy Include="$(DestFldr)/destfldr1"/>
<DestToCopy Include="$(DestFldr)/destfldr2"/>
<DestToCopy Include="$(DestFldr)/destfldr3"/>
</ItemGroup>
<PropertyGroup>
<DestToCopyvar>%(DestToCopy)</DestToCopyvar>
</PropertyGroup>
<Target Name="DeployBatching">
<Copy SourceFiles="#(SrcToCopy)" DestinationFiles="#(SrcToCopy->'$(DestToCopyvar)\%(RecursiveDir)%(Filename)%(Extension)')" />
It's copying just the root files in the root directory, it is missing the directories and sub directories al together ...
This seems to be working for me now ...
<PropertyGroup>
<Srcfldr>C:\Msbuild\exproj\Rebinaries</Srcfldr>
<copyfldr>c$\component1</copyfldr>
</PropertyGroup>
<ItemGroup>
<SrcToCopy Include="$(Srcfldr)\**\*"/>
</ItemGroup>
<ItemGroup>
<DestToCopy Include="\\devsvr1\$(copyfldr);\\devsvr2\$(copyfldr)"/>
</ItemGroup>
<Target Name="DeployBatching" Outputs="%(DestToCopy.FullPath)">
<PropertyGroup>
<DestToCopy>%(DestToCopy.FullPath)</DestToCopy>
</PropertyGroup>
<RemoveDir Directories="#(DestToCopy)"/>
<MakeDir Directories="#(DestToCopy)"/>
<Copy
SourceFiles="#(SrcToCopy)"
DestinationFiles="#(SrcToCopy->'$(DestToCopy)\%(RecursiveDir)\%(Filename)%(Extension)')"
/>
</Target>