My project builds for my teammates, but not for me.
Project:
Errors:
I deleted reference to mscorlib fake, recreated Fake for System, but got the same error.
If I try to add reference to mscorlib, I get message:
A reference to
'C:\Windows\Microsoft.NET\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'
could not be added. This component is already automatically referenced
by the build system.
I tried to add <Reference Include="mscorlib" /> to the project file, but this did not resolve the issue.
I use VS 2017.
Will appreciate any clue.
Thank you #Abhitej, for the answer. It resolved the issue. In addition to switching to higher version of framework I added tags like <Remove FullName="System.Security.Cryptography.CryptoStream"/> for each failing class to both ShimGeneration and StubGeneration in .fakes file.
In most cases like this one its tied to the version of .Net Framework installed on the box. As long as your test project targets the highest version of the Framework on your box, this should work out. Also when dealing with System* namespace please be sure to only generate fakes for types you need excluding others. That should help Fakes deal with API changes over versions and resolve any build errors you might be seeing because of this.
-Abhitej.
Related
My shared library cannot resolve using RestSharp; among other related namespaces. RestSharp is an installed package and is resolvable in the Droid/iOS projects but cannot be found in the Shared Library. I know this works because I'm using RestSharp in a MonoGame project in the same way. The shared library is referenced in the Droid/iOS projects but still fails during compilation.
Any advice? I tried clean all.
Update I created a new Cross Platform Native app solution and I was able to reference in my shared library without issue. That original project is a bit older and was created with PCL originally. I still want to know why it's not working in my original solution.
I continued to have lots of namespace and type not found issues. Once I showed warnings instead of just errors I found that the csproj was missing. After removing the reference in the native apps and re-adding the issue was resolved. Quite frusterating.
I have created a project in Visual Studio 2017 Windows. Now I am trying to work on it from Mac. While tried to build the project I can see reference to Mono.Android is not available. Also System.ComponentModel is unavailable. How I can add the reference for both of it?
I also facing the same issue mono.android is missing, finally it work by adding mono.android.dll. I did something like this in my project, in Deploy.cs file add this line
class Deploy
{
[Android.Runtime.Register("getExternalStoragePublicDirectory", "(Ljava/lang/String;)Ljava/io/File;", "")]
it show missing mono.android.dll library is missing need to add into the project. Problem solved later I comment this line.
From the picture above you can see that the reference is made to a particular file on your Windows computer which on the Mac is obviously not on that path. If you want to make the project work you should find those files on the Mac and reference them. Copying them from Windows somewhere and referencing them should work too.
But as people noted, the point of PCL project is not to contain references like this so whole the architecture of your app is wrong and that's why you see the problems. So you may want to resolve the root of the problem as this probably won't be the last thing that you encounter by doing the things in the wrong way.
I'm getting this error trying to build a Xamarin.iOS project referencing a .NET Standard 2.0 library.
None of the MT2001 issues online seem to have this specific "Error while processing references" reason, so I'm at a loss as to how to diagnose this. I've tweaked and fiddled about as much as any one person can and stay sane, but I'm really in the dark.
Can anyone out there point me in a direction?
Adding -v -v -v -v to "Additional mtouch arguments" in the project iOS Build settings will help diagnose the issue. After that, you can search the build output for MT2001 and view the inner exceptions. Obviously, each project may differ as to what assembly causes the linker to fail. You may need to add, remove or fix your references based on the output.
For example, I was trying to use SignalR from AspNetCore 2.1, which has a dependency on System.Threading.Tasks.Extensions 4.5.1 in my project, which it seems Mono does not yet support. Mono does not provide its own version of the assembly yet, so when mtouch goes to link the assembly, it's unable to do so and throws an exception:
Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
Removing all references to this assembly (and therefore the whole feauture in my case) allowed the build and linking to succeed.
I've found that I get this when using a Xamarin library that is dependent on System.Reactive 4.1.0. There's a bug in there associated with System.Threading.Tasks.Extensions, and since it is a library I'm writing, I had to roll back to System.Reactive 4.0.0.
For me the error is as follows.
one of the package is mentioned in package.config file but it was not available in packages. So i added the missing package from nuget and the app works fine
The error:
Failed to add reference. The package 'SimpleInjector.Integration.WebApi.WebHost.QuickStart' tried to add a framework reference to 'Microsoft.Web.Infrastructure' which was not found in the GAC. This is possibly a bug in the package. Please contact the package owners for assistance.
Cannot find assembly 'Microsoft.Web.Infrastructure'.
First of all. Why the error when I have the dll and reference to it in my project?
Second. How do I fix this?
Obviously I've tried to add the assembly to my GAC with various guides from Mircosoft. None of them makes sense imo.
https://learn.microsoft.com/en-us/dotnet/framework/app-domains/how-to-install-an-assembly-into-the-gac
This results in "Failure adding assembly to the cache: The system cannot find the file specified." I guess that's because it's not a strongly typed name with a key pair or what ever. So I looked into this https://learn.microsoft.com/en-us/dotnet/framework/app-domains/how-to-sign-an-assembly-with-a-strong-name
which makes absolutely no sense. It says:
"In the Choose a strong name key file box, choose , and then navigate to the key file. To create a new key file, choose and enter its name in the Create Strong Name Key dialog box."
What key file? Create a new and just come up with a random name? Wtf? How is that related to a specific assembly?
I faced a similar issue with error "Unable to uninstall 'Ninject.3.2.2' because 'Ninject.Extensions.ChildKernel.3.2.0, Ninject.Extensions.Conventions.3.2.0, Ninject.Web.3.2.0, Ninject.Web.Common.3.2.0' depend on it.".
It was caused by multiple projects in the solution having a dependency on those DLLs and so package manager was not able to uninstall it.
The command with "uninstall package-name -RemoveDependency" too doesn't work here.
I removed the dependency one by one to fix it.
As #Schadensbegrenzer and #LeoLiu-MSFT pointed out, the Infrastrcuture assembly is not part of the .NET framework (anymore).
The issue has been reported as a bug on SimpleInjectors repo:
https://github.com/simpleinjector/SimpleInjector/issues/509
The package owners solution:
"I'll add this issue to the v4.1 backlog, and will fix the NuGet package (and that of SimpleInjector.Integation.MVC3 as well) with v4.1.
In the meantime, you can manually add the Microsoft.Web.Infrastructure NuGet package to your Web API project or don't add the SimpleInjector.Integration.WebApi.WebHost.QuickStart NuGet package to your project, but just the SimpleInjector.Integration.WebApi NuGet package and add the required code manually. The WebHost.QuickStart package is in fact nothing more than a reference to the integration package while injected some code into your application anyway.
The Web API integration page in the documentation describes how to set up a Web API project using Simple Injector."
I have a solution with 4 projects. In the first one I reference the other three, not with Browse, but with Add reference->Project tab.
I have all three using statements in the beginning.
The program works fine. I tested it and it works. But I'm not able to build it.
I get the error "Missing a using directive or an assembly reference".
None of my projects are on client profile. (I think .Net 2.0 doesn't even have client profile).
Why is VS doing this? How to resolve it?
Clean build was the solution. Duh.