Exception has been thrown by the target of an invocation.

Joined
Mar 6, 2024
Messages
7
Programming Experience
1-3
Exception has been thrown by the target of an invocation.:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileLoadException: Could not load file or assembly 'ProjectName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515) ---> System.NotSupportedException: Attempt to load an assembly from a network location that would cause the assembly to be sandboxed in previous versions of the .NET Framework. This version of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If it is not intended to put the assembly in a sandbox, enable the loadFromRemoteSources option. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.

   --- End of inner exception stack trace ---
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
   at System.Data.Entity.Infrastructure.Design.Executor..ctor(String assemblyFile, IDictionary`2 anonymousArguments)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstance(String assemblyString, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.AppDomain.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Data.Entity.Tools.AppDomainExecutor..ctor(String assembly, String dataDirectory, String configurationFile, String rootNamespace, String language)
   at System.Data.Entity.Tools.Commands.ProjectCommandBase.CreateExecutor()
   at System.Data.Entity.Tools.Commands.DatabaseUpdateCommand.Execute()
   at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)
   at System.Data.Entity.Tools.Program.Main(String[] args)
Exception has been thrown by the target of an invocation.


Gentlemen, does anyone have a solution for this exception? I've tried several alternatives
 
I did this, I did practically all the options I found on the internet and in csharpforum. I reinstalled Visual Studio, it didn't solve the problem. Solution that worked: restart my computer (I don't know why, but it worked). This left me quite stressed, but resolved.
 
Yes bro. I already did what he suggested, but it didn't work.

How were we supposed to infer that from your vague?
I've tried several alternatives

You could have told us what "alternatives" you had already tried.

On a closer look, it seems like the crash was from some other program, an Entity Framework tool perhaps, and not from your own code itself. The crash only happened as a result of trying to load presumably your assembly named "ProjectName". This would have also helped us if you told us what that other program was.

You could have also told us whether the error was valid in terms of it detecting that you were trying to load your "ProjectName" assemby from a network drive or not.

And if not, whether "ProjectName" was downloaded from the web and thereby had "the mark of the web" which would have also triggered that error.

Anyway, I'm glad that you managed to resolve your issue, even if it was "fixed by magic".
 
How were we supposed to infer that from your vague?


You could have told us what "alternatives" you had already tried.

On a closer look, it seems like the crash was from some other program, an Entity Framework tool perhaps, and not from your own code itself. The crash only happened as a result of trying to load presumably your assembly named "ProjectName". This would have also helped us if you told us what that other program was.

You could have also told us whether the error was valid in terms of it detecting that you were trying to load your "ProjectName" assemby from a network drive or not.

And if not, whether "ProjectName" was downloaded from the web and thereby had "the mark of the web" which would have also triggered that error.

Anyway, I'm glad that you managed to resolve your issue, even if it was "fixed by magic".

Thank you for your comments, I will pay attention to this in future queries.
 

Latest posts

Back
Top Bottom