MVC3 solution log4net build issue - asp.net-mvc-3

I have a simple MVC solution with 2 projects, domain and web. There is no real magic in there except that when I build the solution a log4net.dll mysteriously appears in my web project's bin folder. I picked this up after my \Views\Shared\Error.cshtml had a squiggly line below the top line (#model System.Web.Mvc.HandleErrorInfo) saying: "Asp.Net runtime error:Could not load file or assembly log4net.............blah,blah,blah"
I do not have a reference to any log4net in any of my projects, how is the dll getting there? I do not even have anything in my web.config with the word log4net in. This is a MVC3 Framework 4 project.

It's possible that you have installed some NuGet package which depends on log4net. If you don't use NuGet packages maybe you have referenced an assembly which depends on log4net. So when this assembly is loaded the log4net assembly is copied as it is a dependent assembly.

Related

Unable to load one or more of the requested types - ASP.NET Core 6.0 Web API

ASP.NET Core 6.0 web app. I get an error when I try to map controllers in Startup.cs. The assembly referenced (QESI.Accuracy.Contract) is a project reference, and it works fine.
The line above it loads a class from that project with no issues. This particular assembly is also packaged and used in other solutions, so I'm wondering if something is trying to load the Nuget package instead of the project reference and that is what's causing it to fail.
If I change the name of the assembly for the project to suffix a 2 I get an error that the same type exists in two assemblies. So something somewhere is referencing the version 1.1.58, which would be the nuget package. I've cleared all nuget package caches using these instructions.

Wrong FSharp.Core version looked for in a Xamarin.Forms project

In a Xamarin.Forms project I am getting an error on Windows 8.1 and UWP:
Could not load file or assembly 'FSharp.Core, Version=3.259.3.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.
The actual version of F# used throughout the solution is 3.7.4.0:
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile>Profile7</TargetFrameworkProfile>
<TargetProfile>netcore</TargetProfile>
<TargetFSharpCoreVersion>3.7.4.0</TargetFSharpCoreVersion>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
There is an F# PCL project and C# platform-specific projects. The error occurs only when using F# libraries from Nuget in the PCL. These packages tend to use:
<TargetFSharpCoreVersion>3.259.3.1</TargetFSharpCoreVersion>
I have tried the following, but they do not change the error:
Putting an app.config file with a binding redirect to 3.7.4.0 in the F# project and/or the build directory
Installing the FSharp.Core Nuget package into all projects
Very grateful for any help.
Edit: in the original question there was an incompatibility between the profile (111) and the intended TargetFSharpCoreVersion (3.7.4.0) which was causing additional issues.

Visual Studio Team Services Build Issues

I am using Visual Studio Team Services as source control and have enabled continuous integration.
My project is an ASP.NET application which used Entity Framework 5. When i checkin the code and the build controller tries to build it, the following errors come up
DataModel\GenomicsTutorDataModel.Context.cs (40): The type or
namespace name 'DbSet' could not be found (are you missing a using
directive or an assembly reference?)
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets
(1578): Could not resolve this reference. Could not locate the
assembly "EntityFramework". Check to make sure the assembly exists on
disk. If this reference is required by your code, you may get
compilation errors.
In my solution i have made system.data.entity CopyLocal = True yet no success.
Any ideas?
May be you are on a 64 bits machine and the TFS server is not?
Try to build your project for Any CPU or x86.
Add the DLL you referenced for System.Data.Entity into a folder in your project or somewhere in a folder in the Source Control and reference to that one. Check this in and try to build your application again.

System.Web.Mvc missing error while building ASP.NET MVC 3 using NAnt

My MVC 3 project is building successfully in my development machine with Visual Studio 2010 + MVC 3. In the build server, VS2010 is not used and I've installed 'ASP.NET MVC 3 Tools Update'. I've also downloaded NAnt and used TortoiseSVN to checkout all the files except bin directories.
But while building using Nant default.build, I'm getting build error
'The type or namespace name 'Mvc' does not exist in the namespace
'System.Web'
(are you missing an assembly reference?). Same with 'Controller', 'ActionResult', 'GlobalFilterCollection' etc (type or namespace could not be found).
I can see System.Web.Mvc.dll in
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Web.Mvc\v4.0_3.0.0.0__31bf3856ad364e35\
. What am I missing here? Why NAnt can't find this file? Is there no other way than copying the assembly files into local bin?
I had the same issue and wasn't able to locate the System.Web.MVC reference assembly.
Finally found out and it was located inside the following location.
Note if your VS was installed in C: (Sometimes the MVC is not in the defaul location which everybody talk about, i mean the "Reference Assemblies" folder located in the C: drive.
if its not there, it should definitely be in here:
Program files(x86) --> Microsoft ASP.NET --> ASP.NET MVC 2 --> Assemblies System.Web.Mvc.dll
Hope this one is helpful.
Here is my answer -
Best way is to use NuGet package manager.
Just update the below MVC package and it should work
Why is System.Web.Mvc not listed in Add References?
If you use NuGet packages, you need to update MVC package. This worked for me.
If you Installed MVC Package from NuGet packages. simply uninstall package and install it again.
It's work for me
Which version of msbuild are you using to build the web project?
Is the web project referencing a specific version of or file path to System.Web.Mvc.dll?
Download and install ASP.NET MVC 3:
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=4211
According to: http://weblogs.asp.net/scottgu/archive/2011/05/03/asp-net-mvc-3-tools-update.aspx
"The ASP.NET MVC 3 Tools update only includes Visual Studio tooling improvements and default project template changes – it does not include any changes to the ASP.NET MVC 3 runtime binaries."

How do I use Fluent NHibernate with .NET 4.0?

I want to learn to use Fluent NHibernate, and I'm working in VS2010 Beta2, compiling against .NET 4, but I'm experiencing some problems.
Summary
My main problem (at the moment) is that the namespace FluentNHibernate isn't available even though I've imported all the .dll assemblies mentioned in this guide.
This is what I've done:
1. I downloaded the Fluent NHibernate source from here, extracted the .zip and opened the solution in VS. A dialog asked me if I wanted to convert the solution to a VS2010 solution, so I did.
2. I then went into each project's properties and configured all of them to compile for .NET 4, and built the entire solution.
3. I copied all the .dll files from /bin/Debug/ in the FluentNHibernate to a new folder on my local hard drive.
4. In my example project, I referenced FluentNHibernate.dll and NHibernate.dll from the new folder.
This is my problem:
If I right-click on FluentNHibernate in the References list and select "View in Object Browser...", it shows up correctly.
Now, when I try to create a mapping class, I can't import FluentNHibernate. This code:
using FluentNHibernate.Mapping;
namespace FluentNHExample.Mappings
{
}
generates an error on the using statement, saying
The type or namespace 'FluentNHibernate' could not be found (are you missing a using directive or an assembly reference?).
The FluentNHibernate assembly is still in the list of References of my project, but if I try to browse the assembly in Object Browser again, it can't be found.
What is causing this?
I also had similar problem.
"Error List" window displayed:
The type or namespace name 'FluentNHibernate' could not be found (are you missing a using directive or an assembly reference?)
But "Output" window was displaying detailed information:
warning MSB3253: The referenced assembly "FluentNHibernate" could not be resolved because it has a dependency on "System.Data.OracleClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which is not in the currently targeted framework ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies not in the targeted framework or consider retargeting your project.
In my case; I had created a console application project which was targeting ".Net Framework 4 Client Profile" by default, so changing to ".Net Framework 4" fixed issue for me.
I'm unable to observe this behavior in my build, could it be related to this problem: Weird override problem with Fluent NHibernate and .NET 4
If so you could try http://groups.google.com/group/fluent-nhibernate/browse_thread/thread/ae4013d711d2e4ad as a potential fix.
Isn't there a better way to fix this problem?
I don't want to reference System.Data.OracleClient. So I shouldn't have to target the full .Net framework if I don't even want that reference.
Can't I target the Client Profile of the .Net framework, but add a compiler warning exception somewhere so that it just skips that warning? I know it won't cause a runtime problem because I don't use Oracle.
I get identical problem which says there's also a dependency on System.Web. Same story, this is for a Windows WPF app, so I don't need System.Web. Can't I just target the Client Profile and somehow convince the compiler to keep going?
Thanks,
Hugh
EDIT: I figured this out! I had to compile NHibernate myself though. Opened the 2.1.2 code in Visual Studio and deleted everything that says "Oracle" or "System.Web" and I ended up getting it to build. I do not have to target the full .Net Framework now.
We had this issue and the issue went away if we removed the obj and bin folder from the project which was referencing the NHibernate using project.
So we have 'project1' which uses NHibernate to produce project1.dll.
'project2' references project1.dll.
Problem resolved if we removed the obj/bin folder from project2.
Can't say why, but our solution now compiles fine.
Mike.

Resources