SignedCms alternative in .NET Core - c#

Does an alternative to System.Security.Cryptography.Pkcs.SignedCms class exist in .NET Core? Or do I have to dig into BouncyCastle, like they do in WinRT case? Is there an alternative of SignedCMS in WinRT?

FYI in case it helps. It seems that support for SignedCms and other essential .NET classes for S/MIME are available via this NUGET package:
System.Security.Cryptography.Pkcs
I.e. before I added this NUGET package to my Visual Studio 2017 (VS2017) .NET Core project, I received these compilation errors:
Severity Code Description Project File Line Suppression State
Error CS0246 The type or namespace name 'CmsRecipientCollection' could not be found (are you missing a using directive or an assembly reference?)
Error CS0246 The type or namespace name 'X509IssuerSerial' could not be found (are you missing a using directive or an assembly reference?)
Error CS0246 The type or namespace name 'EnvelopedCms' could not be found (are you missing a using directive or an assembly reference?)
Error CS0246 The type or namespace name 'SignedCms' could not be found (are you missing a using directive or an assembly reference?)
Error CS0246 The type or namespace name 'SignerInfoCollection' could not be found (are you missing a using directive or an assembly reference?)
Error CS0246 The type or namespace name 'ContentInfo' could not be found (are you missing a using directive or an assembly reference?)
Error CS0246 The type or namespace name 'CmsRecipient' could not be found (are you missing a using directive or an assembly reference?)
Error CS0246 The type or namespace name 'RecipientInfo' could not be found (are you missing a using directive or an assembly reference?)
Error CS0103 The name 'SubjectIdentifierType' does not exist in the current context
Error CS0246 The type or namespace name 'SignerInfo' could not be found (are you missing a using directive or an assembly reference?)
Error CS1579 foreach statement cannot operate on variables of type 'SignerInfoCollection' because 'SignerInfoCollection' does not contain a public instance definition for 'GetEnumerator'
Error CS0246 The type or namespace name 'CmsSigner' could not be found (are you missing a using directive or an assembly reference?)
After I added the NUGET package, I could compile successfully.

No, there's no equivalent to SignedCms in .NET Core at this time.
You're quite welcome to create an issue on https://github.com/dotnet/corefx/issues to indicate that it's a type that you would like to be brought over.

Related

Type Support does not exist after upgrade to Xamarin.Forms 5

I've updated Xamarin.Forms Nuget package from 4.8.0.1560 to 5.0.0.1874. After this I got the following errors:
The type or namespace name 'Support' does not exist in the namespace
'Xamarin.Android' (are you missing an assembly reference?)
The type or namespace name 'Net' does not exist in the namespace
'MyProject.Android' (are you missing an assembly reference?)
The type or namespace name 'Graphics' does not exist in the namespace
'MyProject.Android' (are you missing an assembly reference?)
The type or namespace name 'App' does not exist in the namespace
'MyProject.Android' (are you missing an assembly reference?)
I've deleted bin and obj folders, clean and rebuild solution, but nothing.
Any suggestion?
The steps required to upgrade an app from Xamarin.Forms 4.x to 5.x are provided by Microsoft, here:
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/troubleshooting/questions/forms5-migration

I can build this project in VS but not with msbuild

I'm trying to build a ms test project in a nuget app.
My project structure is this:
MyPackage
--> MyPackage
--> MyPackageTest
If I open VS and right click and build MyPackageTest it works. If I go to cmd and type this I fails:
msbuild .\MyPackageTest\MyPackageTest.csproj /T:build "/p:Configuration=Release"
I get errors like this:
"C:\Users\me\MyPackage\MyPackageTest\MyPackageTest.csproj" (build target) (1) ->
(CoreCompile target) ->
MyTests.cs(2,17): error CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [C:\Users\me\MyPackage\MyPackageTest\MyPackageTest.csproj]
MyOtherTests.cs(2,17): error CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [C:\Users\me\MyPackage\MyPackageTest\MyPackageTest.csproj]
MyOtherTests.cs(13,4): error CS0246: The type or namespace name 'TestClassAttribute' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\me\MyPackage\MyPackageTest\MyPackageTest.csproj]
MyOtherTests.cs(13,4): error CS0246: The type or namespace name 'TestClass' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\me\MyPackage\MyPackageTest\MyPackageTest.csproj]
MyTests.cs(13,4): error CS0246: The type or namespace name 'TestClassAttribute' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\me\MyPackage\MyPackageTest\MyPackageTest.csproj]
MyTests.cs(13,4): error CS0246: The type or namespace name 'TestClass' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\me\MyPackage\MyPackageTest\MyPackageTest.csproj]
MyOtherTests.cs(17,6): error CS0246: The type or namespace name 'TestMethodAttribute' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\me\MyPackage\MyPackageTest\MyPackageTest.csproj]
MyOtherTests.cs(17,6): error CS0246: The type or namespace name 'TestMethod' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\me\MyPackage\MyPackageTest\MyPackageTest.csproj]
MyOtherTests.cs(38,6): error CS0246: The type or namespace name 'TestMethodAttribute' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\me\MyPackage\MyPackageTest\MyPackageTest.csproj]
MyOtherTests.cs(38,6): error CS0246: The type or namespace name 'TestMethod' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\me\MyPackage\MyPackageTest\MyPackageTest.csproj]
MyOtherTests.cs(59,6): error CS0246: The type or namespace name 'TestMethodAttribute' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\me\MyPackage\MyPackageTest\MyPackageTest.csproj]
MyOtherTests.cs(59,6): error CS0246: The type or namespace name 'TestMethod' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\me\MyPackage\MyPackageTest\MyPackageTest.csproj]
MyOtherTests.cs(75,6): error CS0246: The type or namespace name 'TestMethodAttribute' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\me\MyPackage\MyPackageTest\MyPackageTest.csproj]
MyOtherTests.cs(75,6): error CS0246: The type or namespace name 'TestMethod' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\me\MyPackage\MyPackageTest\MyPackageTest.csproj]
MyOtherTests.cs(91,6): error CS0246: The type or namespace name 'TestMethodAttribute' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\me\MyPackage\MyPackageTest\MyPackageTest.csproj]
MyOtherTests.cs(91,6): error CS0246: The type or namespace name 'TestMethod' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\me\MyPackage\MyPackageTest\MyPackageTest.csproj]
MyTests.cs(16,6): error CS0246: The type or namespace name 'TestMethodAttribute' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\me\MyPackage\MyPackageTest\MyPackageTest.csproj]
MyTests.cs(16,6): error CS0246: The type or namespace name 'TestMethod' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\me\MyPackage\MyPackageTest\MyPackageTest.csproj]
MyTests.cs(36,6): error CS0246: The type or namespace name 'TestMethodAttribute' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\me\MyPackage\MyPackageTest\MyPackageTest.csproj]
MyTests.cs(36,6): error CS0246: The type or namespace name 'TestMethod' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\me\MyPackage\MyPackageTest\MyPackageTest.csproj]
MyTests.cs(50,6): error CS0246: The type or namespace name 'TestMethodAttribute' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\me\MyPackage\MyPackageTest\MyPackageTest.csproj]
MyTests.cs(50,6): error CS0246: The type or namespace name 'TestMethod' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\me\MyPackage\MyPackageTest\MyPackageTest.csproj]
MyTests.cs(65,6): error CS0246: The type or namespace name 'TestMethodAttribute' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\me\MyPackage\MyPackageTest\MyPackageTest.csproj]
MyTests.cs(65,6): error CS0246: The type or namespace name 'TestMethod' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\me\MyPackage\MyPackageTest\MyPackageTest.csproj]
MyTests.cs(81,6): error CS0246: The type or namespace name 'TestMethodAttribute' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\me\MyPackage\MyPackageTest\MyPackageTest.csproj]
MyTests.cs(81,6): error CS0246: The type or namespace name 'TestMethod' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\me\MyPackage\MyPackageTest\MyPackageTest.csproj]
EDIT: to add, msbuild also throws this error: Could not locate the assembly "Microsoft.VisualStudio.QualityTools.UnitTestFramework"
I can build this project in VS but not with msbuild
First of all, if you use CMD to call MSBuild, please make sure that you set the right path for the path of the Environment Variables. Just like C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin(VS2017 Community version and the MSBuild.exe exists in this path).
Besides, l assume you have a local project called MyPackageTest which created by the local VS and then you migrate it to the build server without VS.
Actually, the issue could be caused by the missing packages which lost during migration to build server. Meanwhile,MSBuild with command line will not restore the missing packages since you have migrated it into the Build Server. However, when you use VS IDE, the build process will restore the missing packages automatically during the build process.(Tools-->Options-->Nuget Package Manager-->General-->Packages Restore).
Suggestion
So please run the msbuild -t:restore first to restore the required packages.(Go to the project path first and do this).
Then type this below:
msbuild .\MyPackageTest\MyPackageTest.csproj /T:build "/p:Configuration=Release"
In addition, you would better use Build Tool for VS2019 or Build Tool for VS2017 and please make sure that the build tool version is the same as the VS version which creates the project.
Second, when you use Build Tool, also make certain that you have installed the Testing tools core features in the individual components of vs installer.
Hope it could help you.
Try running msbuild in a new cmd window everytime as a temporary workaround.
This works everytime for me and is what I currently do. I think running msbuild(with or without vsdevcmd) changes some environmental variables/settings which affects the subsequent msbuild runs.
I faced the same problem a while ago which greatly affected my productivity. I think it started after upgrading to VS2019. My solution didn't involve any nuget packages, but msbuild would fail randomly with these errors.

Azure deployment fails with build errors

I have been trying to deploy my web application to azure for two days now. I had finished programming the application and its working properly locally, when i pushed to application to github, and I'm using my student starter plan to deploy it. The application starts deploying then it fails with errors. The errors are below
/usr/share/dotnet/sdk/3.0.100/Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.Extensions.Identity.Stores". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/home/vsts/work/1/s/SchoolManager.Models/SchoolManager.Models.csproj]
Administration/SchoolRole.cs(1,17): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [/home/vsts/work/1/s/SchoolManager.Models/SchoolManager.Models.csproj]
Administration/SchoolUser.cs(1,17): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [/home/vsts/work/1/s/SchoolManager.Models/SchoolManager.Models.csproj]
Tenancy/TenancyRole.cs(1,17): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [/home/vsts/work/1/s/SchoolManager.Models/SchoolManager.Models.csproj]
Tenancy/TenancyUser.cs(2,17): error CS0234: The type or namespace name 'AspNetCore' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [/home/vsts/work/1/s/SchoolManager.Models/SchoolManager.Models.csproj]
Administration/SchoolRole.cs(5,31): error CS0246: The type or namespace name 'IdentityRole<>' could not be found (are you missing a using directive or an assembly reference?) [/home/vsts/work/1/s/SchoolManager.Models/SchoolManager.Models.csproj]
Administration/SchoolUser.cs(7,31): error CS0246: The type or namespace name 'IdentityUser' could not be found (are you missing a using directive or an assembly reference?) [/home/vsts/work/1/s/SchoolManager.Models/SchoolManager.Models.csproj]
Tenancy/TenancyRole.cs(5,32): error CS0246: The type or namespace name 'IdentityRole<>' could not be found (are you missing a using directive or an assembly reference?) [/home/vsts/work/1/s/SchoolManager.Models/SchoolManager.Models.csproj]
Tenancy/TenancyUser.cs(7,32): error CS0246: The type or namespace name 'IdentityUser' could not be found (are you missing a using directive or an assembly reference?) [/home/vsts/work/1/s/SchoolManager.Models/SchoolManager.Models.csproj]
1 Warning(s)
8 Error(s)
I had even changed the host now to Azure DevOps but it still show me the same thing. This has pushed me to rewrite the application from start. It runs locally okay but when i publish it, it fails.
I too faced the same issue. While publishing VS build was failing with - Unable to find dependent project references, but with release version I was able to build the solution.
The fix which worked for me was -
Update VS version to Version 16.7.3.
With this version project build passed successfully and I was able to deploy the packages...in earlier version I think there was a problem with dependency resolver.

.NET framework System.Windows.Form on non Windows OS

So, I MUST use C# for a uni course, just like I MUST use MSSQL Server, the big problem is that I'm running Ubuntu. I followed this guide, I mean it's from microsoft right? Can't get any of System.Windows.Form working, neither SqlDataAdapter and many more(like 99.65% of the libraries).
Anyone encountered this issue before? Or you just created a VM and waited a week for Visual to install?
This is what I get when I run dotnet run
Program.cs(4,22): error CS0234: The type or namespace name 'Forms' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?) [/home/potra/Desktop/School/School/DBMS/Test/Test.csproj]
Program.cs(8,28): error CS0246: The type or namespace name 'Form' could not be found (are you missing a using directive or an assembly reference?) [/home/potra/Desktop/School/School/DBMS/Test/Test.csproj]
Program.cs(10,17): error CS0246: The type or namespace name 'DataGridView' could not be found (are you missing a using directive or an assembly reference?) [/home/potra/Desktop/School/School/DBMS/Test/Test.csproj]
Program.cs(11,17): error CS0246: The type or namespace name 'DataGridView' could not be found (are you missing a using directive or an assembly reference?) [/home/potra/Desktop/School/School/DBMS/Test/Test.csproj]
Program.cs(12,17): error CS0246: The type or namespace name 'SqlDataAdapter' could not be found (are you missing a using directive or an assembly reference?) [/home/potra/Desktop/School/School/DBMS/Test/Test.csproj]
The build failed. Please fix the build errors and run again.
The latest .NET Core, 2.1 Preview 2, does not include System.Windows.Forms.
If you'd like to use a native Ubuntu runtime, Mono supports WinForms and SqlClient.
For more information, the .NET documentation explains how .NET is implemented.

TeamCity compilation error

I'm having an issue with Teamcity.
While running a build of my project in Visual Studio being passed successfully, running this "build" in Teamcity results with some errors difficult to understand.
These are the errors I'm getting from TeamCity:
AppealPersonDetails.cs(29, 7): error CS0246: The type or namespace name 'Tlv' could not be found (are you missing a using directive or an assembly reference?)
AppealPersonDetails.cs(32, 7): error CS0246: The type or namespace name 'Excel' could not be found (are you missing a using directive or an assembly reference?)
AppealReportAddAnotherApplication.cs(29, 7): error CS0246: The type or namespace name 'Tlv' could not be found (are you missing a using directive or an assembly reference?)
AppealReportDetailsPage.cs(29, 7): error CS0246: The type or namespace name 'Tlv' could not be found (are you missing a using directive or an assembly reference?)
FinishProcessPage.cs(29, 7): error CS0246: The type or namespace name 'Tlv' could not be found (are you missing a using directive or an assembly reference?)
MainStatusPage.cs(29, 7): error CS0246: The type or namespace name 'Tlv' could not be found (are you missing a using directive or an assembly reference?)
MainTestRunner.cs(27, 7): error CS0246: The type or namespace name 'Tlv' could not be found (are you missing a using directive or an assembly reference?)
MainTestRunner.cs(31, 7): error CS0246: The type or namespace name 'Excel' could not be found (are you missing a using directive or an assembly reference?)
Queries.cs(13, 7): error CS0246: The type or namespace name 'Tlv' could not be found (are you missing a using directive or an assembly reference?)
StatusApplicationsPage.cs(29, 7): error CS0246: The type or namespace name 'Tlv' could not be found (are you missing a using directive or an assembly reference?)
StatusPage.cs(29, 7): error CS0246: The type or namespace name 'Tlv' could not be found (are you missing a using directive or an assembly reference?)
Any third party dependencies that would be in the GAC on your machine will need to be in the GAC or locally locatable on your build server.
I would check the location of the assemblies that contain the Tlv and Excel namespaces and go from there. If the Excel namespace is due to depending on the Office Interop Assemblies, you will need the correct version of Excel installed on the build server.
Edit based on comments:
OP clarified that he was using references to the assemblies directly rather than project references. When he switched to using project references, the build order was correctly established and his problem was solved.

Categories

Resources