Could not load file or assembly 'AspNet.Loader, Version=1.0.0.0' - asp.net-core

im using ASP.NET 5 MVC6, and i am getting this error whenever i try to run application:
An attempt was made to load an assembly from a network location which
would have caused the assembly to be sandboxed in previous versions of
the .NET Framework. This release of the .NET Framework does not enable
CAS policy by default, so this load may be dangerous. If this load is
not intended to sandbox the assembly, please enable the
loadFromRemoteSources switch. See
http://go.microsoft.com/fwlink/?LinkId=155569 for more information.
and when i dive a little deeper in error i find this:
Could not load file or assembly 'AspNet.Loader, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null' or one of its dependencies.
Operation is not supported.
I tryed googling it, but no luck, any ideas?
Thanks in advance!

I have had this issue when deploying to Azure as well. My only solution was to make sure the file and permissions on the folder wwwroot/bin are such that the server can see and access this directory.

Related

Error CS0433 The type 'WebUtility' exists in two places

I'm creating an asp.net core app using Visual Studio 2017. I'm trying to encode a URL component using web utility.
var value = System.Net.WebUtility.UrlEncode("some text here");
When I include that in my code, I see the below error. I'm at a loss as to finding the issue. I see no project.json file. I have searched for anyplace where System.Runtime.Extensions are being included.
I have the following packages installed: AspNetCore, AspNetCore.Mvc, AspNetCore.StaticFiles, .netCore.App, PaulMiami.AspNetCore.Mvc.Recaptcha
I have tried to remove the captcha package without it fixing the issue.
Error CS0433 The type 'WebUtility' exists in both 'System.Runtime.Extensions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Other posts I've seen about this issue ask for a project.json file, which I don't seem to have. Any thoughts?
Update 1:
I tried to create a new asp.net core web app - all defaults out of the box, I then installed the PaulMiami.AspNetCore.Mvc.Recaptcha package, the call to WebUtility works fine in the newly created app. There must be something I'm not finding in the existing application that is causing this issue.
I found the problem.
Under “Dependencies” I noticed an entry for Assemblies, and in that was an entry for “System”. I’m not sure how it got there, but after removing it my issue went away and the app compiles.
In the future, I’ll be sure to check this location. Of note, the newly created out of the box asp.net core web app I created had no entry for Assemblies in the Dependencies list. I must have added a package and then removed it, which caused this issue. (perhaps the asp.net pre-.net core captcha framework by mistake?)

Could not load file or assembly 'NetTopologySuite, Version=1.13.4693.18484

ok, here's the situation.
I have two projects:
ASP.NET MVC 4 (references class library)
Class Library (Added RavenDB and Net Topology Suite from NuGet)
When I try to run 'SpatialGenerate' in any index, I get the following error:
Could not load file or assembly 'NetTopologySuite, Version=1.13.4693.18484, Culture=neutral, PublicKeyToken=f580a05016ebada1' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I am using .net 4.5 of course and I'm doing this in VS 2012 on Windows 8. I have tried hosting this in IIS/IISexpress and the cassini server. I have checked that the file and it's related files are all present in the bin/debug directories and their versions are accurate. I also created a unit test that calls the queries via the index and I get the same error.
I have searched everywhere and I can't seem to find anything. Furthermore, once I was able to execute the index and everything worked, but I don't know why and can't make it happen again.
You need to use the RavenDB.Ebmedded package or add RavenDB.Database

Missing MySQL DLL?

I've recreated the Northwind Spring/NHibernate example that comes with Spring.NET, but with MySQL rather than SQLServer. I've almost got it working I think, but I'm getting this when I try to use Hibernate to load something from the database
A first chance exception of type 'System.IO.FileNotFoundException'
occurred in mscorlib.dll NHibernate.Util.ReflectHelper:
ERROR lambda_method - Could not load type
MySql.Data.MySqlClient.MySqlCommand, MySql.Data.
System.IO.FileNotFoundException: Could not load file or assembly
'MySql.Data' or one of its dependencies.
The system cannot find the file specified.
File name: 'MySql.Data'
Every project (DAO, Service, Web) has a reference to the MySQL.Data DLL so I'm a bit unsure what's going on.
Can anyone help me please?
Make sure that MySQL.Data.dll actually got copied to the output folder. And that you are using right platform (x32 vs x64 bit) and right version of .NET (2,3,3.5 vs 4). If everyhing seems fine, enable Fusion Logging and take a look at this article:
For FileNotFoundException: At the bottom of the log will be the paths
that Fusion tried probing for this assembly. If this was a load by
path (as in Assembly.LoadFrom()), there will be just one path, and
your assembly will need to be there to be found. Otherwise, your
assembly will need to be on one of the probing paths listed or in the
GAC if it's to be found.
You may also get this exception if an unmanaged dependency or internal
module of the assembly failed to load. Try running depends.exe on the
file to verify that unmanaged dependencies can be loaded. Note that if
you re using ASP.NET, the PATH environment variable it's using may
differ from the one the command line uses. If all of them could be
loaded, try ildasm.exe on the file, double-click on "MANIFEST" and
look for ".file" entries. Each of those files will need to be in the
same directory as the manifest-containing file.

Unable to load type NHibernate.ByteCode.Castle.ProxyFactoryFactory

As I read and try every topic similar without success, I decided to post my own question. My solution has a console app and a class library for dataaccess. The Nhibernate configuration is inside the appconfig in the console app (which I'm currently using for debug, as I will after make a Web App and migrate all configuration to web.config).
The exception is well know:
NHibernate.Bytecode.UnableToLoadProxyFactoryFactoryException: Unable to load type NHibernate.ByteCode.Castle.ProxyFactoryFactory,NHibernate.ByteCode.Castle.dll' during configuration of proxy factory class. Possible causes are: - The NHibernate.Bytecode provider assembly was not deployed. - The typeName used to initialize the 'proxyfactory.factory_class' property of the session-factory section is not well formed. Solution: Confirm that your deployment folder contains one of the following assemblies: NHibernate.ByteCode.LinFu.dll NHibernate.ByteCode.Castle.dll ---> System.IO.FileNotFoundException: Could not load file or assembly 'NHibernate.ByteCode.Castle.dll' or one of its dependencies. The system cannot find the file specified.
The steps I took to try to solve it:
1) The dll in the deployment folder - I have the following dll in my bin:
Castle.Core.dll - v. 2.5.1
Iesi.Collections.dll - v.2.0.0.1002
log4net.dll - v. 1.2.10.0
NHibernate.ByteCode.Castle.dll - v.3.0.0.2001
NHibernate.dll - v.3.1.0.4000
2) The configuration contains
name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory,NHibernate.ByteCode
3) I set my MetaManager.Data project to deploy in a x86 CPU
4) All dll in my bin folder are referenced in the project.
I think this it it. I do not know were else to go :(
To find out which dlls are loaded or rejected by which component you can use the "Assembly Binding Log Viewer" (Fuslogvw.exe) that belongs to the dotnetsdk . If logging is enabled it can show you wich assemblies are loaded and which assembly caused it to load.
For details see http://msdn.microsoft.com/en-us/library/e74a18c4(v=vs.80).aspx
I think the version of the Iesi.Collections and NHibernate.ByteCode.Castle assemblies should be the same as for the NHibnernate assembly, i.e. 3.1.0.4000 (at least that's the version of the assemblies distributed with NH 3.1.0 GA).

WCF The service '/myservice.svc' activated due to an exception during compilation

Our current deployment strategy is to deploy all assemblies with each application / service but control where *.exe and service implementaion assemblies are deployed. With that in mind, I have a specific service that when I deploy 2 unreferenced resource assemblies I get a compilation error. System.IO.FileNotFoundException: Could not load file or assembly '****.resources, Version=1.0.1262.0, Culture=fr, PublicKeyToken=null' or one of its dependencies
I do not have the sub folders for each language deployed in the bin folder e,g, "fr" etc.
Can somebody tell me why these "unreferenced" assemblies are causing compilation errors?
Most of the time this kind of error can be attributed to a View referencing a resource by a resource key. This would cause an ASP.NET compile time error.
You can check to see what the requesting DLL is by using fuslogvw.exe to figure out what the binding error is. If it's a DLL with an obscure name like ASP.jwnca.dll this is probably the case.
Why not just deploy these files?
Hope this helps.