I created a class library. The default version was 1.0.0, and then I updated the class and again created the package using this (dotnet pack -p:PackageVersion=1.0.1 -o \packages) command. I realized that I used the wrong directive in the class and the package was created on the wrong path as well. I changed the directives and created again with the same command with same 1.0.1 in a correct folder. I am unable to refer in other classes with using directive. The compiler does not understand that. When I reference 1.0.2 in csproj package reference then the compiler sees that.
Are these versions immutable? Why removing does not work? How can I make it use version 1.0.1? I have spent hours trying different things, and I do not seem to solve this. Help needed please.
Related
The following line gives an error saying it doesn't exist in the current content.
Interaction.InputBox("Enter Version", "", "default");
I read other questions about this I did every possible way;
Added reference to Microsoft.VisualBasic from project add section, also included;
using Microsoft.VisualBasic;
I don't understand why it creates problem.
Probably you've got an old version of the Microsoft.VisualBasic.dll.
Click on Dependencies > Frameworks > Microsoft.NETCore.App > Microsoft.VisualBasic.
Then look in the Properties window.
There you should see ..\net5.0\Microsoft.VisualBasic.dll.
If you see ..\netcoreapp3.1\Microsoft.VisualBasic.dll - that's too old.
To get the new Microsoft.VisualBasic.dll you have to base your App on .NET 5.0.
I have the same error as yours. I solved it by adding Microsoft.VisualBasic reference through Nuget package tool instead of by myself.
Propably the dll version in our system is too old, and Nuget can install the correct one.
I'm trying to add reference to System.Configuration.dll assembly.
I'm using .Net Core, as it can be seen in my .csproj file:
<TargetFramework>netcoreapp2.2</TargetFramework>
(Output type of my project is set to Class Library.)
To do this, in solution explorer, I right-click on Dependencies of my project and then click on Add Reference.... Problem is that the opened Reference Manager is empty and there is no assembly I can add a reference to.
However, without referencing that assembly I'm able to write the following line without any build error:
using System.Configuration;
First Question: How is it possible that the above line gets successfully built, without me referencing that assembly?
If I try to use ConfigurationManager class to read data from app.config file (As told here ), I get an error complaining that:
CS0103 The name 'ConfigurationManager' does not exist in the current context
Question two: what can I do to solve that error? what's wrong with my code or project?
My case is not the same as this question and this is not a duplicate of that question.
Add Reference is for your local references. You need to use Nuget Package Manager in order to include references.
most importantly .Net Core does not use .Net Framework packages where ConfigurationManager is .Net Framework package.
You need to use .Net Core or .Net Standard libraries with .Net Core
I am working on an Asp.Net MVC 4 Application in which I am using SignalR 2.0.1 and I Mapped it using Owin Startup class and it worked fine at first.
All of a sudden when I tried to rebuild my app it said that the type are namespace IAppbuilder could not be found.
Following is my start up class
using Microsoft.Owin;
using Owin;
using WhiteBoardApp;
namespace WhiteBoardApp
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.MapSignalR();
}
}
}
I have installed Owin package too, and for some reasons I could not find Owin Startup class so I just added a normal class and included all the references that are needed.
May I know where I am making a mistake
Try to use Package Manage Console and do
Update-Package Owin -Reinstall
I was having similar issue. But instead Owin, problem was causing Microsoft.Owin, obviously
Update-Package Owin -Reinstall
Didn't work, neither did Update-Package Owin
BUT
Install-Package Microsoft.Owin
did work fine for me, thanks.
The IAppBuilder interface is found under Owin package. Just add a reference in your class file:
using Owin;
And rebuild. Your project will pick this up.
I have no idea why VS didn't pick this up, but it didn't. Once I added this reference to my project, then everything fell into place.
I encountered the same problem while building my project. Here are the steps that helped fix my problem:
Go to Solution Explorer and look for your project
Under your project, expand the References; You should see warnings on the problematic reference
Right click References and open Manage NuGet Packages
Search the name of problematic reference i.e. Microsoft.Owin; After loading it shows that it is already installed (It is, but it installed incorrectly. Checking the properties > version at step 2 shows 0.0.0.0)
Check Force uninstall, even if there are dependencies on it
Uninstall
Install
Build and run the project
Problems
Cannot install Microsoft.Web.Infrastructure because it already exists in the packages folder. Rolling back...
Go to your project folder and look for packages
Find the problematic package i.e. Microsoft.Web.Infrastructure
Delete the folder
Resume from step 7
Alternatives
Here are the alternatives I've read about to fix this kind of problem.
Clean and Rebuild Project / Solution
Restart Visual Studio
Restart PC
Good luck.
My Visual Studio 2013 for some reason didn't realize that the references paths existed. The yellow exclamation mark in front of the references was shown for all the added packages. I checked ../packages/ but all files existed, i also opened the .csproj file which referenced the correct paths.
Closing and opening the solution returned quite a lot of errors, and could not load the projects included in the solution.
Restarting Visual Studio 2013 saved the day for some unexplained reason.
My following using's equivalent in F# present a problem of hiding the IAppBuilder. It turns out that the Owin stipulation was being interpreted as an incomplete System.Web.Http.Owin reference, even though the Owin.dll providing the Owin namespace was referenced.
open System.Net.Http
open System.Web.Http
open Microsoft.Owin
open Owin
The problem was resolved by rearranging the usings as follows:
open Microsoft.Owin
open Owin
open System.Net.Http
open System.Web.Http
...granted, this may be a bug peculiar to the F# compiler and name conflicts are handle better in C# and elsewhere.
In my case, I had moved around the project folders and the location of the vs solution file (.sln). Once I was done with re-adding the projects, there was a packages folder on the solution level and one was left in a project sub folder.
This way, in that project, the relative package folder links in the .csproj file got messed up.
The reinstallation or other tips regarding the nuget package manager in this thread were helpful. I noticed, that after I reinstalled a few packages, in my git source code diff, the path of the packages folder was changed within the csproj file.
Before
<HintPath>packages\Microsoft.Owin.4.0.1\lib\net45\Microsoft.Owin.dll</HintPath>
After
<HintPath>..\packages\Microsoft.Owin.4.0.1\lib\net45\Microsoft.Owin.dll</HintPath>
So, if you run in the same issue and you have a lot of nuget packages, it might be easier to close the whole solution, open the csproj file(s) in a text editor like vscode and fix the relative links with search and replace. Then just save, close, reopen solution in VS and restore nuget packages. That should do the trick.
(In any case, you should delete the local packages folder on the project level, so that the project really fails, if it does not get the right packages.)
It's an ordering issue.
using Microsoft.Owin;
using Owin;
Leads to Microsoft.Owin to be defined first, then Owin is found under already imported Microsoft namespace. If you mouse over Owin of using Owin you should see it was resolved to Microsoft.Owin again and furthermore IDE will gray out using Owin as redundant unused reference.
Do:
using global::Owin;
Which clarifies for the compiler not to look for Owin under already defined namespaces (e.g. Microsoft. namespace).
http://www.asp.net/signalr/overview/getting-started/tutorial-getting-started-with-signalr
Check for the visual studio you are using
You can find the following comment
Note: If you are using Visual Studio 2012, the SignalR Hub Class (v2) template will not be available. You can add a plain Class called ChatHub instead.
Also
Note: If you are using Visual Studio 2012, the OWIN Startup Class template will not be available. You can add a plain Class called Startup instead.
I am trying to locate PerRequestLifetimeManager. In MSDN, it says that it is part of the Unity 3 assembly.
I've installed Unity.Mvc4 via Nuget. The package.config says I am using Unity 3.0:
The Microsoft.Practices.Unity.dll says I am using Unity 3.0
I looked inside the DLL using object browser, and the PerRequestLifetimeManager is no where to be found.
Am I missing something here?
If someone will suggest an alternative class, I am planning to use a custom PerRequestLifetimeManager found here (if I am unable to find the class).
EDIT:
I've uninstalled Unity.Mvc4 and directly installed the Unity3.0 in the package console, here is what I got:
PM> Install-Package Unity -version 3.0.1304.1
'Unity 3.0.1304.1' already installed.
Successfully added 'Unity 3.0.1304.1' to RedLions.Presentation.Web.
I still can't find the PerRequestLifetimeManager class, even in the official library.
It seems not good to answer my own question when I just instead did it on my own. I can no longer delete my question.
Anyway, here was my solution.
I went straight to the source code of Unity, I found out that the class does exist in the same namespace but not in the same assembly. PerRequestLifetimeManager is in Microsoft.Practices.Unity.Mvc
I checked MSDN and it did say that its in a different DLL, which I failed to notice. Sorry about that.
It is not part of the Unity package in nuget, but in a different package in Nuget (Unity.Mvc), so here it is: http://www.nuget.org/packages/Unity.Mvc/
I decided to dump Unity.Mvc4 as it is no longer needed, everything is already in the Unity.Mvc. (App_Start/UnityConfig.cs)
you can delete the original DLLS and Uninstall the reinstall.
Run the following from PCM, Package Manager Console:
Install-Package Unity.Mvc
This will give you the DLL Microsoft.Practices.Unity.Mvc where it is.
Today after deploying some changes to a C# MVC site that I run, I went back to make some more modifications and came across this error:
Missing compiler required member System.Runtime.CompilerServices.ExtensionAttribute..ctor
The error is a bit vague (other than it's description, obviously) as it doesn't give me a file, line, or column to reference, only the project. Also, it throws the error a total of 20 times. I only made three changes to the code between the time I deployed (it was completely functional at that time) and now. I reverted my changes and it is still throwing the same error which makes no sense to me.
I haven't found a lot of information on this error on SO or Google, other than this guys solution and a couple references to some Mono project errors (I'm not using Mono). The solution the guy above gives requires adding a class definition that will allow the compiler to resolve the reference. I don't particularly want to do this because I haven't needed to do it up until this point and it will just muddy my code.
Just curious if anyone has run across this before.
In my case it was because the project was not referencing Microsoft.CSharp. Once I added a reference to that assembly, it compiled just fine.
I don't know if anyone else has experienced this, but I suddenly ran into this error after adding some code utilizing dynamic types and incorporating WebAPI into a project that originated as a TypeScript application in VS2013. Simply adding a reference to Microsoft.CSharp resolved my issue.
Hope this helps someone else.
This error usually means either your project is compiling against .NET 2.0 or you aren't referencing the correct version of System.Core.dll
For a near duplicate question, see Error when using extension methods in C#
I ran into this situation as well today. In my case I was referencing the Newton.Json.Net dll v3.5 in my .NET 4.0 application. I realized that I wasnt even using this library, thus once I removed it from my references, it no longer gave me the compiler error.
Problem solved!!!
The actual error comes from the fact that your 2.0 assembly that causes the error contains this code:
namespace System.Runtime.CompilerServices
{
public class ExtensionAttribute : Attribute { }
}
The Code Above allows the .NET 2.0 Assembly to use extension methods (see Using extension methods in .NET 2.0?). While it confuses the compiler if you target .NET 4.0 and reference a 2.0 Assembly (containing above code) as the mscorlib.dll(4.0) contains the same class in the same namespace.
I fixed this
by compiling the original 2.0 assembly again without the attribute targeting 4.0
by removing the assembly (obviously)
by adding a third Extension Attribute in the target you compile (it seems to overrule the referenced definitions)
Writing this code somewhere in your project may solve your problem. It works for me
namespace System.Runtime.CompilerServices
{
public class ExtensionAttribute : Attribute { }
}
Probably you use dynamic keyword In .NetStandard Class library project. If so, you need to add a reference to Microsoft.CSharp library in the project. Hope it will resolve your problem.
NLog.dll 2.0 referenced from a .NET 4.0 project can cause this too.
I don't have a correct solution, but I'll add my data point:
In my case the error is caused by referencing GoogleSearchAPINet20
Here is what happens:
I close the solution that builds
I open the solution again. It still builds
As soon as I make any change and try to build, I get 19 "Missing compiler required member ..." errors
I remove the reference to GoogleSearchAPINet20
I add back the reference to GoogleSearchAPINet20
I build the solution. It builds without errors
I can now make code changes, build or perform any other actions with solution correctly as long as my Visual Studio is open
I close Visual Studio
Repeat from step one
I'm not referencing System.Core.dll in my solution at all and my target framework is .NET 4.
I'm a bit annoyed at this point ...
Got this error when trying to use async Tasks against .NET 4.0. Updating Target Framework to 4.5.2 fixed the problem.
I hit the same set of exceptions after I added some async methods to a winforms project. I needed to bump my .NET version from 4 to 4.5
For me, the problem occure when I add asynchronous method with async Task await in my .net4.0 project !
With previous versions of the .NET-Framework 4.5, you must install this package:
Install-package Microsoft.Bcl.Async –pre
or
Install-Package Microsoft.CompilerServices.AsyncTargetingPack
more info on Nuget or Nuget