Code analysis CA0001 error for project using NSubstitute - visual-studio-2010

I have a (.NET 4) test project which references (the .NET 4) NSubstitute.dll.
When I run CodeAnalysis against the project I get a number of CA0001 errors:
Running Code Analysis...
MSBUILD : error : CA0001 : The following error was encountered while reading module 'NSubstitute': Could not resolve type reference: [mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]System.Runtime.CompilerServices.ExtensionAttribute.
MSBUILD : error : CA0001 : Rule=Microsoft.Interoperability#CA1404, Target=arcplan.test.engage.admin.ecmFramework.CAppSettingsTest.#IsSettingsStoreReadyToUse_SettingsStoreIsNotReady_ReturnsFalse() : The following error was encountered while reading module 'ECMFrameworkTest': Method type parameter in position 0 is not valid.
MSBUILD : error : CA0001 : Rule=Microsoft.Security#CA2122, Target=arcplan.test.engage.admin.ecmFramework.CAppSettingsTest.#IsSettingsStoreReadyToUse_SettingsStoreIsNotReady_ReturnsFalse() : The following error was encountered while reading module 'ECMFrameworkTest': Method type parameter in position 0 is not valid.
(etc.)
Does anyone know how to solve this?

Are you using version 1.4.1? The build of this version had a problem caused by using ilmerge with .NET 4.5 installed. This is fixed as of version 1.4.2 of NSubstitute (the latest release as of this comment).
More details are available on the commit to fix this.

Related

Blazor Server project is not running after installing Blazorise.Snackbar component

In my Blazor Server project I have been using blazorise controls. I started this project 3 months before. Now I wanted to use Blazorise.Snackbar component. So I ran nuget package command to install the component. Now my project is not running. It shows exception in the below lines of code in the Program.cs file
builder.Services.AddBlazorise(options => { options.Immediate = false; })
.AddBootstrap5Providers()
.AddFontAwesomeIcons()
.AddBlazoriseRichTextEdit();
The error message is:
System.TypeLoadException: 'Method 'FocusTrap' in type
'Blazorise.Bootstrap5.Bootstrap5ClassProvider' from assembly
'Blazorise.Bootstrap5, Version=1.0.4.0, Culture=neutral,
PublicKeyToken=null' does not have an implementation.'
My Current Packages version:
Can anyone help me to solve the problem?
You should use the same version on all Blazorise packages to ensure that they are compatible with each other. Changing Blazorise.Snackbar version to 1.0.4 will fix your problem.

Dapper and .net core 3

Im new to .netcore and trying to use dapper for some db interactions. Does dapper not work with .net core 3? Or am I doing something wrong :X
I created a new .net project:
dotnet new mvc
tried to add dapper
dotnet add package Dapper --version 2.0.30
Then I get the error:
info : Adding PackageReference for package 'Dapper' into project
C:\repos\dapper\dapper.csproj'.
info : Restoring packages for C:\repos\dapper\dapper.csproj...
error: Cycle detected.
error: dapper -> Dapper (>= 2.0.30).
info : Package 'Dapper' is compatible with all the specified frameworks in project 'C:\repos\dapper\dapper.csproj'.
error: Value cannot be null. (Parameter 'path1')
The reason is that csproj has the same name as the dependant PackageReference dapper,refer to https://github.com/NuGet/Home/issues/6754
A project and a dependency cannot have the same name.
Change the name of your project(not using dapper) will overcome it.

Integration testing in ASP.NET Core Microsoft.AspNetCore.Mvc.Razor.Compilation.CompilationFailedException

For this error, I have tried multiple solutions which is provided by Github. But, none of them worked. Please help to check whether this issue reopen on new environment like below.
Environment:
VS 2017 Version 15.4.1
Dotnet Version 2.0.2
Reproduce Steps:
Create an Asp.Net Core Web Application->.NET Core and Asp.net Core 2.0-> Web Application(Model-View-Controller)
Create an xUnit Test Project(.NET Core)
Follow this link Integration testing in ASP.NET Core
Add true to Test.csproj which is pointed at above link.
Run test method will return below error.
Microsoft.AspNetCore.Mvc.Razor.Compilation.CompilationFailedException : One or more compilation failures occurred:
ewiqttdv.z4g(4,62): error CS0012: The type 'Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
Update:
After following this suggestion , this error gone, but, it produce below new error.
Message: System.IO.FileNotFoundException : Could not load file or assembly 'Microsoft.VisualStudio.Web.CodeGeneration, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
What is the possible way to resolve "Microsoft.AspNetCore.Mvc.Razor.Compilation.CompilationFailedException"?
Any help would be appreciated.
A bit late, but I ran in to the same problem today and managed to fix the "Could not load file or assembly 'Microsoft.VisualStudio.Web.CodeGeneration ..." error by adding the following reference to my integration test project:
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.1" PrivateAssets="All" />

Build SSIS project with Visual Studio 2013

I have to automate the way we build and deploy our SSIS projects.
We use VS2013, SQLSERVER2014 and TFS2015. I'm already aware of two solutions:
1) MSBuild: I followed this blog https://speaksql.wordpress.com/2013/06/07/a-journey-to-db-deployment-automaton-ssis-build-using-msbuild/ and it works fine for VS2010 but unfortunately not for VS2013.
The error I'm getting is:
Project "SSISTest\SSISTest\SSIS.MSBuild.proj" on node 1 (SSISBuild target(s)).
SSISBuild:**************Building SSIS project: ..\SSISTest\SSISTest.dtproj for onfiguration: Development**************
------
Loading project file '..\SSISTest\SSISTest.dtproj'
Setting output directory to '..\SSISTest\bin\Development'
Setting project ProtectionLevel to 'DontSaveSensitive'
Loading package '..\SSISTest\Package.dtsx'
error : Error while loading package '..\SSISTest\Package.dtsx': The package failed to load due to error 0xC0011008 "Error loading from XML. No further detailed error information can be specified for this problem because no Events object was passed where detailed error information can be stored.". This occurs when CPackage::LoadFromXML fails.\r
error :
error : The package failed to load due to error 0xC0011008 "Error loading from XML. No further detailed error information can be specified for this problem because no Events object was passed where detailed error information can be stored.". This occurs when CPackage::LoadFromXML fails.\r
error : \r
error : at Microsoft.SqlServer.Dts.Runtime.Package.LoadFromXML(String packageXml, IDTSEvents events)\r
error : at Microsoft.SqlServer.IntegrationServices.Build.DeploymentFileCompilerTask.LoadPackage(String path)\r
error : at Microsoft.SqlServer.IntegrationServices.Build.DeploymentFileCompilerTask.Execute()
Done Building Project "SSISTest\SSISTest\SSIS.MSBuild.proj" (SSISBuild target(s)) -- FAILED.
2) devenv: works fine but our projects are all protected with a password, and everytime you try to build it prompts the dialog to insert the password.
Is there any other way I can automate this in VS2013?
I'll answer myself. After adding the proper dll references (expecially the Microsoft.SqlServer.ManageDTS one) for VS2013 to the http://sqlsrvintegrationsrv.codeplex.com/SourceControl/latest project, generating the .dll allowing MSBuild to build SSIS project as suggested by https://speaksql.wordpress.com/2013/06/07/a-journey-to-db-deployment-automaton-ssis-build-using-msbuild/, worked just fine. I'm now able to automatically build SSIS projects with MSBuild and deploy them to a SQL Server 2014 instance.

LinkAssemblies fails after upgrading to MVVMCross 4.0

I have just updated a large Xamarin project from MVVMCross version 3.5 to 4.0. I have fixed all namespace issues and bugs, but I am stuck with this bug:
The "LinkAssemblies" task failed unexpectedly.
Xamarin.Android.XamarinAndroidException: error XA2006: Reference to metadata item
'System.Boolean Android.OS.BaseBundle::GetBoolean(System.String,System.Boolean)'
(defined in 'MvvmCross.Droid.FullFragging, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=null') from 'MvvmCross.Droid.FullFragging, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=null' could not be resolved. --->
Mono.Cecil.ResolutionException:
Failed to resolve System.Boolean Android.OS.BaseBundle::
GetBoolean(System.String,System.Boolean)
I have added MvvmCross.Droid.FullFragging.* to linkerConfig.xml, but to no avail.
I experienced the same issue. The MvvmCross dlls are build to version v6.0 for android. I noticed the following output tab (My logging is set to verbose).
warning XA0105: The $(TargetFrameworkVersion) for MvvmCross.Binding.Droid.dll (v6.0) is greater than the $(TargetFrameworkVersion) for your project (v5.0).
When I changed the projects to Android 6.0 I still received the linker error. When I opened the project file in a text editor I noticed that was defined twice. Once in the global property group set to 6.0 and once in the Debug property group set to 5.0. I removed the following line from the Debug property group and the issue went away.
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
What you need to do is to switch on verbose logging in your build. For iOS specify verbose logging by adding:
-v -v -v -v
To the extra build parameters textbox. Then run the build again.
For Android you can do this in the Visual Studio Tools -> Settings -> Xamarin -> Android settings -> Xamarin Diagnostics.
You will probably identify that some packages are of different versions and will cause this linking issue.
You will find some clues to the issue using verbose logging. I have only mentioned the verbose logging for this platform as its the platform I have most experience with at the moment.
This is the best answer I can offer as this issue can be caused by a truly massive number of issues and will be individual to each solution.

Resources