0

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

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.