Last week I created a ASP.NET 5 MVC project using VS.NET 2015 Preview. I then used NuGet to get the MongoDB driver (mongocsharpdriver) and I wrote some code and with that added some documents to the database. I started a new project today along those same lines but it wouldn't build. It says the type or namespace MongoDB can't be found even though I have intellisense for it. So I opened the original project and now that one won't build, same exact error. My project properties is set to target CLR, not Core -- that MongoDB library doesn't work with Core. Has anyone run into this problem and know how to fix it? I'm pretty sure I'm not going crazy.
All I do to reproduce the problem is start a new ASP.NET Web Application, then pick ASP.NET 5 Starter Web, then install MongoDB from NuGet, then add an import to it in the HomeController.cs. Then it complains about it not being found in Core, even though I'm not targeting Core.
This is the error when compiling following my steps above:
Error CS0246 The type or namespace name 'MongoDB' could not be found (are you missing a using directive or an assembly reference?) Bug.ASP.NET Core 5.0 HomeController.cs
As per my best knowledge ASP.net core 5.0 framework does not support many of existing Nuget library and assembly.
Go to project.json and remove ASP.net Core 5 from framework section.
Related
I have a solution with multiple projects, the notable projects are:
ContractProject
DataProject
WebProject
WebProject is a .NET Core project, the other two are .NET Framework.
This is the file structure, including the csproj and sln files:
DataProject references Dapper, which is a NuGet package.
When attempting to run the build configuration in TeamCity, I get the following (slightly reduced, redacted) error:
DapperWorklistRepository.cs(4,7): error CS0246: The type or namespace name 'Dapper' could not be found (are you missing a using directive or an assembly reference?) [REDACTED_PATH_TO_DATAPROJECT_CSPROJ_FILE]
......
Build FAILED.
......
Process exited with code 1
Step Build (.NET Core (dotnet)) failed
This is my only build step (.NET Core):
Any idea what I'm doing wrong? I have a feeling it may be something to do with the web project not being able to reference the projects one level back? I have tried setting the required paths in many different ways with no avail.
I ended up figuring this out, implementing a bit of a hack of a solution.
The problem lies in the fact that I'm referencing .NET Framework projects from a .NET Core project, and attempting to build them all in one step.
The work around required two things:
Firstly, I had to include a NuGet installer build step. I couldn't figure out how to target specifically .NET Framework projects (it doesn't support .NET Core), so I essentially duplicated the solution file, renamed it to NetCoreBuildHelper, and deleted the Web project reference. The reference remained in the original solution. I then referenced the new NetCoreBuildHelper solution in the NuGet Installer.
Secondly, I had to create a .NET Framework MSBuild step, which built the other projects (DataProject and ContractProject), referencing the NetCoreBuildHelper solution.
I'd love to hear responses to this if I could improve the solution, as it feels like a bit of a hack
This question is on the older side - but I'm interested in knowing if you arrived at any more information.
To the best of my knowledge, .Net Framework and .Net Core are fundamentally different platforms, so they are not meant to be referenced by one other. .Net Standard projects however, are intended to be a vehicle for code sharing that both .Net Core and .Net Framework can reference, as long as the Standard version being targeted is the correct version. For example, .Net Framework 4.8 is, at most, .Net Standard 2.0 compatible. If the .Net Framework projects were class libraries, it might be worth migrating those to be .Net Standard projects, and reference them from your .Net Core project.
I have a ASP.NET Core 1.0 MVC app in solution X and I have some common projects (.net 4.5.2 class libs) in solution Y.
I want to reference the projects in solution Y from my app, when I do so via add reference -> Browse .. I get:
.NET Core projects only support referencing .NET framework assemblies in
this release. To reference other assemblies,
they need to be included in a NuGet package and reference that package.
I then created a nuget package of those projects, added the folder that contains the nuget packages as a repo source and loaded the projects. This adds the projects successfully to my project.json, but 'nothing' else actually happens, I still can't use the code in my app.
Now ASP.NET Core is past its beta status, what is the official way of dealing with this?
Many people have struggled with this issue and there is a long running thread on GitHub about it. Even the people using the latest RC3 build are reporting the same problem that you are having.
The only way I've been able to reference class library projects in an ASP.NET Core web application is to create both the web application and the class library projects in Visual Studio 2015 Update 2. And they all have to target .NET Framework 4.6.1.
I had to copy the code from my old class library projects to the new ones. But in the end I think I saved myself time by not having to mess with all the workarounds that don't seem to work for a lot of people.
I used the RC version of Visual Studio 2012 to create an ASP.NET Webforms project and I intentionally took the 4.0 version of .Net and of the project template to avoid complications after the release of VS2012.
Now I anyway bumped into the problem, that is revealed in the following error message:
'jquery' is not a valid script name. The name must end in '.js'.
As I noticed in the references, following assembly references are broken:
Microsoft.ScriptManager.jQuery
Microsoft.ScriptManager.jQuery.UI.Component
System.Web.Providers
I tried to re-install jQuery using NuGet but did not find these assemblies.
If I now create a new .Net 4.0 ASP.NET Webforms project in Visual Studio 2012 I get a lot of new references which are not present in my current (originally created in the RC-version, now opened in VS2012 RTM), like:
AspNet.ScriptManager.jQuery
AspNet.ScriptManager.jQuery.UI.Combined
but I can't find them among reference sources if I try to add a new reference to my original project.
How can I make my application runnable in VS2012?
Check packages
AspNet.ScriptManager.jQuery.1.7.1
AspNet.ScriptManager.jQuery.UI.Combined.1.8.20
make sure the following dlls are in the lib folder
AspNet.ScriptManager.jQuery.dll
AspNet.ScriptManager.jQuery.UI.Combined.dll
And check the reference in your project to make sure all references are resolved.
Sometimes, the dlls didn't added to the source control and when you do a get latest from the source control these two dlls are missing.
I'm using VS 2010 with ASP.net MVC 2.
I recieved a program that was completed and when I was debugging the program I recieve an error message.
"Error 4 The type 'System.Web.Routing.RouteTable' exists in both 'C:\Program Files\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.Web.dll' and 'C:\Documents and Settings\Vincent\Desktop\3\Manning.ASP.NET.MVC.2.in.Action.Jun.2010\aspnetmvc2inaction_code\lib\AspNetMvc\System.Web.Routing.dll' C:\Documents and Settings\Vincent\Desktop\3\Manning.ASP.NET.MVC.2.in.Action.Jun.2010\aspnetmvc2inaction_code\src\Chapter01\GuestBook\Global.asax.cs"
and
"Error 1 The type 'System.Web.Routing.RequestContext' exists in both 'c:\Program Files\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.Web.dll' and 'c:\Documents and Settings\Vincent\Desktop\3\Manning.ASP.NET.MVC.2.in.Action.Jun.2010\aspnetmvc2inaction_code\lib\AspNetMvc\System.Web.Routing.dll' C:\Documents and Settings\Vincent\Desktop\3\Manning.ASP.NET.MVC.2.in.Action.Jun.2010\aspnetmvc2inaction_code\src\Chapter01\GuestBook\Controllers\AccountController.cs".
The program was converted into VS 2010 format.
What should I do?
// Fullmetalboy
When you convert a project from .Net 2.0/3.5 to 4.0 in VS2010 the web projects will prompt you to upgrade the framework to 4.0 but you will need to manually go into the project properties and upgrade class library projects and certain other projects manually in the project properties. So this type of error is probably caused by your web project referencing the 4.0 version of System.Web.Routing but a class library in your solution is still referencing the 3.5 version.
One of the projects in your solution is referencing a single type (RouteTable/RequestContext) in two different places. I always start with cleaning and rebuilding the solution, but if that doesn't fix it, you're going to have to check the project references and resolve it that way. If all else fails, try to make a new project from scratch and manually add the references and projects you need and then copy and paste your old code.
Someone copied the ASP.NET MVC source code into the "lib" folder of your application and either included that folder in the project (so it is getting built when you build your project) or he/she built it before you got it and referenced it from within the project. Now it is in conflict with the ASP.NET libraries that exist in default installation folder on the system 'c:\Program Files\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.Web.dll'.
Since you're using the .NET 4.0 Framework, the library System.Web.Routing is ambiguous. Make sure you have referenced System.Web.dll (version 4.0) and remove the reference to System.Web.Routing.dll
I am done testing my site and I want to upload it to a site like this
http://www.university.edu/mydepartment/myname
the admin told me the server runs on .NET 3.5. So i used Linq ...
now i tried to upload the site by two ways:
when i just copy everything (with modification of web.config database settings) i get an error:
CS0246: The type or namespace name
'DataClassesDataContext' could not be
found (are you missing a using
directive or an assembly reference?)
Version Information: Microsoft .NET
Framework Version:2.0.50727.3082;
ASP.NET Version:2.0.50727.3082
Note here it says version 2.0
did he just lie to me? or its my configuration mistake?
anyway, i added the reference, nothing changes.
I tried also publishing (Build, publish) with option to keep the pre-comiled site updatable, and I get one line saying:
this is a makefile and should be
deleted!
what is going on?
It looks like it can't find your DBML file, or your DBML file isn't called "DataClasses.dbml". Also, the .NET Framework Version is not lying. It is reporting the CLR version, which is still 2.0 for the 3.5 .NET Framework.