I'm trying to use xbuild from mono to compile my C# web application. I keep running into this error:
Field 'System.Text.RegularExpressions.Regex.IsMatch' not found.
The only thing that I've been able to find about this error is to add 'System' as an assembly reference in the csproj file which I already had there. I also tried installing the 'System.Text.RegularExpressions' NuGet package and putting an assembly reference of 'System.Text.RegularExpressions' in the csproj file. Neither of those worked.
One thing I should note here. This error only gets thrown in my test library. I can build everything else fine without the tests but I need to be able to build the tests as I'm trying to set up CI that runs the tests. The tests are using NUnit.
Here's the data for what I'm using:
XBuild Engine Version 14.0
Mono, Version 4.8.0.0
C# 6
.NET Framework 4.5.2 (but have tried building with 4.5.0, 4.0.0, and 4.3.0)
I figured out what this problem was. We were using Selenium for UI tests and the drivers for that were preventing the build from completing for some reason. As far as what part in Selenium was causing this, I'm not sure.
Related
I am working with the NUnit test in visual studio. On visual studio 2019, it running fine with no errors. But when I am making an azure pipeline for the same I am getting the multiple errors in the VSTest step just after VSBuild step.
I am attaching the screenshot defining the errors.
Help me with suitable solution if any.
According to this comment on this GitHub issue:
The problem is that System.Runtime.Loader is not supported on .NET Framework, this is a package that will only work on .NETCore App and UAP. We used to rely on a NuGet feature that wouldn't let this package install when targeting .NET Framework so you would get errors about this at compile time, but they changed this feature and now permit you to install the package and compile, so you now hit the error at runtime which is less than ideal. We could consider building a new version of this package that better stated that it is not supported on .NET Framework so that the incompatibility is found at compile-time.
The only solution seems to be use a different target framework.
I downloaded the .NET SDK for the Froala WYSIWIG HTML Editor. The download link is available here: https://www.froala.com/wysiwyg-editor/docs/sdks/dotnet
Simply download the zip, extract it and open it.
When compiling the solution inside Visual Studio 2019, I don't have any Errors/Warnings. No problem either at runtime.
When opening the exact same solution inside Visual Studio Code, I got some errors when compiling (dotnet build) even if compilation succeed. And no problem at runtime.
The errors are mainly Reference type 'HttpContext' claims defined 'System.Web', but not found
As stated here it may be a problem of targetting 2 different .NET framework versions.
The solution (.sln) is composed as below:
src project
demo-core project (referencing src project) <--- set as default project
demo project (referencing src project) <---- not used because I use demo-core
I was not able to find a solution for this annoying error warning at compilation.
UPDATE 1
src project is targetting the net472;netstandard2.0
demo-core project is targetting the .NET Core 2.0
UPDATE 2
I finally succeed get rid of compilation errors. I simply removed net472 from targetted framework of the src projet and immediately compilation errors disappeared.
What did I have ton conclude ? How this modification impacts Visual Studio Code and why this is not necessary under Visual Studio 2019. Sorry but this is strange to me.
None of the original sources downloaded from that site (and also verified in github commit history) reference net472; they instead reference net471. I suspect the solution was first tried in Visual Studio 2019 and, not having the .NET SDK 4.7.1 targeting pack installed, an attempt was made to retarget SDK 4.7.2.
Once you do this and re-open the source in VS Code, the Omnisharp extension attempts compilation for the first target framework found due to poor support for multiple target frameworks. In this case, the first found for the src project is net472 (which is important). Note that flipping the order of target frameworks doesn't have any effect.
The error "Reference type 'HttpContext' claims defined 'System.Web', but not found" is now straight-forward to explain. If we look for example in src/Image.cs, we see the following using statements:
using System;
using System.IO;
using System.Collections.Generic;
#if netcore
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.StaticFiles;
#else
using System.Web;
#endif
If the src project is "compiled" by the Omnisharp server using net472, it will import System.Web.HttpContext. The demo-core project in Controllers/FoalaApiController.cs compiled for netcore2.0 instead references Microsoft.AspNetCore.Http.HttpContext. These obviously don't match.
Had Omnisharp selected the proper netcore2.0 target for the src project, then these would have matched. It didn't so you see these errors reported by Omnisharp. You don't see these errors from dotnet build or VS2019 because they properly resolve the correct target framework for the src project.
Here's what I first experienced when I downloaded the source. It's not clear what .NET Core SDK version you're using. When I build the source I see the following error with .NET Core SDK 2.2.100.
error NU1003: PackageTargetFallback and AssetTargetFallback cannot be used together. Remove PackageTargetFallback(deprecated) references from the project environment.
The fix for this error is simple: remove the PackageTargetFallback declaration from the .csproj files. After this, the project compiles without errors / warnings using dotnet build.
I didn't see any other errors in VS Code initially because I too did not have the .NET SDK 4.7.1 targeting pack installed. Consequently, Omnisharp could only compile the src project using netstandard2.0.
I have problem in C# development in monodevelop tool for unity.
In that many methods and Interfaces not found like IEnumerator and Array.Length.
I found Same question but it's not work for me.
because solution of that question is import System.Collections namespace but I was already imported it then also throw compile time error.
I Have installed latest .Net Framework on Windows 8.1 Os.
How i solve this problem?
I have had that problem before. I was using the latest .net framework and I went to Programs and Features within control panel (if you're using Windows) and selected the box to also run .net framework 3.5 I think it was.
I then shut down my project after saving, restarted my machine and it worked fine
Close the project from MonoDevelop by doing Right Click. And open the *.sln file manually in MonoDevelop
I'm using Debian and I had your error, this error, and both was fixed by installing these packages:
mono-reference-assemblies-2.0
mono-reference-assemblies-3.5
Using APT:
sudo apt install mono-reference-assemblies-2.0 mono-reference-assemblies-3.5
We recently tried to upgrade our software to .net 4.0. We ran into a small snag and rather than spend the time to try to track everything down we decided to revert back to .net 3.5.
We have encountered a few issues like .resx files not properly reverting, but they have been fixed. The final problem we have encountered is a few projects are not building via command line now (everything was before). The error in all cases is as follows.
The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?)
We use Visual Studio 2010, msbuild for the command line builds, every project has been changed to a framework of 3.5. The projects will still build in the IDE, but it is fairly time consuming for us to build them all by hand, rather than by our automated script.
It would also be worth noting that all the projects that aren't building are web projects. Within the web.config I don't see a single version=4.0.0.0 reference.
CodesInChaos was partially right. While the UI showed a reference to System.Core, there was no actual reference in the .csproj file. This had to be added in manually. This explains why the UI would build, but the command line wouldn't.
I started using Thrift about a week ago. I got the latest source from SVN and built the C# library (Thrift.dll). I used the library to prototype a TCP client/server with the data types that my team will be using. This worked with no problem, I just followed the example code in the SVN repo.
Yesterday, I wanted to run the same test but over HTTP instead. I searched around online some and found out that from the time I got the code last week until yesterday patch "THRIFT-322" https://issues.apache.org/jira/browse/THRIFT-322
Was applied to the trunk. So I updated my thrift source from SVN and saw the new THttpHandler class. I rebuilt the Thrift.dll so I can use the THttpHandler class but now whenever I reference the new dll Visual Studio 2010 gives me an error at compile time: "The type or namespace "Thrift" could not be found (are you missing a using directive or an assembly reference?)". When I replace the reference with the old Thrift.dll that I have I do not get this error.
I can't figure out what I'm doing wrong, I just recompiled the Thrift.dll from the SVN source and I can no longer link to the Thrift.dll. When I first add the reference it seems like it's going to work fine. Visual Studio gives me the correct intellisense, etc. Once I try to build it's like there is no longer a reference to the Thrift.dll. Any ideas?
I also submitted this to the Thrift Users Mailing List, I just thought maybe this was more general and someone here may be able to help.
Thanks,
-Sean
Since you mentioned using VS 2010... I have seen this error/behavior sometimes when I am compiling a .NET 4.0 project and my target framework for the project is set to ".NET Framework 4.0 Client Profile" instead of ".NET Framework 4.0". So you might want to check that and see if it helps.
I had a similar problem I had to switch from '.NET Framework 4.0 Client Profile' to '.NET Framework 4.0' and it worked because a referenced dll is compiled using the '.NET Framework 4.0'
One Suggestion I have is to check for a file with 'refresh' in the extension E.g. Thrift.dll.refresh or something similar. This file is usually added on adding a refernce. Try removing this file, replace the dll and try builtign and running again.