Copying assembly into appharbor output without reference in web project - appharbor

I have just deployed by first website to appharbor. One problem I came across was pre-compiling the razor .cshtml file giving an error that it couldn't find the Nancy.ViewEngines.Razor.BuildProviders.dll assembly. The build provider is just referenced from the web.config file without a direct hard reference. I am assuming that, because the assembly wasn't referenced anywhere, it was not being copied to the appharbor output folder. Consequently when the asp.net compiler tried to execute, it failed because the razor build provider was missing.
The way I got around this was to reference the assembly in the web project. It now builds and deploys fine. But, it's a bit dirty and I wondered if there was another way to do it?

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.

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.

Debug with mvc 3 source code

i've downloaded the mvc3 source code and am trying to add it to an existing project so i can debug. I get the following compile error - The referenced assembly System.Web.WebPages.dll was not found. If this assembly is produced by another one of your projects, please make sure to build that project before building this one. Do these dlls not come with the source code?
Inside the mvc3-rtm-sources.zip you have downloaded there are 2 folders:
mvc3
webpages
It is the webpages folder that contains the WebMatrix stuff (System.Web.Helpers, System.Web.Razor, System.Web.WebPages, ...). So make sure you have compiled those projects first.

MVC application cannot load assemblies

I have a solution that has a class library that references some third party .Net assemblies. Those third party assemblies have dependencies on non-.Net assemblies. The non-.Net assemblies do not copy to the bin folder, which results in an error "Could not load xxx assembly or one of its dependencies". So I created a pre-build event to copy them to the bin folder and this solved the problem.
Then when I referenced my project from a console project in the same solution, I got the same error so I did the same thing with a pre-build event in the console project. Again, that solved the problem.
Now, when I reference the class library project from an MVC application in the same solution I get the same error. But using the same pre-build event that worked in the other two situations does not solve the problem for the web app. I've tried using both the development server and IIS, but get the same error. I've also tried adding a handler to AssemblyResolve in the Application_Start() in the Global.asax to see what is going on, but it doesn't fire.
Do I need to put the files somewhere other than the bin directory for a web app?
Win 7, IIS 7, VS 2010, .Net 4, MVC 3
The reason this doesn't work in ASP.NET is because in ASP.NET managed assemblies get shadow copied in a temporary folder so at runtime the unmanaged libraries cannot be found. For them to be found they need to be present in a folder that is part of the PATH environment variable. Or put them in the c:\windows\System32\Inetsrv folder.

MVC3 solution log4net build issue

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.

Resources