41

I have a WPF application . While building it I am getting the following error:

Could not load file or assembly or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

Application is trying to load the assembly from virtual drive (as debug Folder)

Ex: [subst r: c:[my Assembly bin pth]

Earlier I was mounting c:\bin as a netwwork drive and was getting te following error.

This assembly may have been downloaded from the Web. If an assembly has been downloaded from the Web, it is flagged by Windows as being a Web file, even if it resides on the local computer. This may prevent it from being used in your project. You can change this designation by changing the file properties. Only unblock assemblies that you trust. See http://go.microsoft.com/fwlink/?LinkId=179545 for more information.

Edit: I am not able to find the Unblock button in properties window by the way.

Bo Persson
  • 90,663
  • 31
  • 146
  • 203
Simsons
  • 12,295
  • 42
  • 153
  • 269
  • 1
    This [answer](https://stackoverflow.com/a/11743430/465053) from a related post is very helpful. – RBT Jul 25 '17 at 05:56
  • Hi @Simsons, none of the following answers has been accepted, and I'm wondering if the root cause has anything to do with the virtual drive created by the `subst` command, as I am experiencing exactly the same as yours, of my project resides in the virtual drive. – xpt Nov 18 '21 at 16:41

9 Answers9

100

Clear out the temporary framework files for your project in:

For Windows 7, the path is:

C:\Users\[username]\AppData\Local\Temp\Temporary ASP.NET Files\

For 64 bit systems with 'Framework' in the path the full path is:

C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\

http://www.solutioncottage.com/ShowSolution.aspx?solID=59

shA.t
  • 16,580
  • 5
  • 54
  • 111
Anupam Roy
  • 1,654
  • 2
  • 18
  • 25
10

Removing all temp files from the path below still works, it saved my development site hosted on a web server from (HRESULT: 0x80070057 (E_INVALIDARG))

C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\

Ryan Boken
  • 453
  • 4
  • 11
6

On Visual Studio 2019 I was able to fix this manually deleting the ".vs" folder into the solution directory.

Thanks

Ernest
  • 2,039
  • 24
  • 19
4

this happened to me when i got a blue screen while building.

i had to delete my packages and bin folders, and get then from TFS

at that time i had nothing in the following location...

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files

to resolve i set Visual Studio in debug mode and then monitored the above directory. i deleted the files as they appeared and then the app started working again.

time to start looking for a new Dev machine.

JGilmartin
  • 8,683
  • 14
  • 66
  • 85
1

For the Error which you were getting when you were mounting is due to blocking for Assemblies/DLL. Right click on what ever DLL's you have downloaded and you will get an option to unblock it .

For the Could not load file or assembly or one of its dependencies error, put a breakpoint in the constructor of the starting class and check it is failing due to what.

adityaswami89
  • 573
  • 6
  • 15
1

I was encountering this problem after a windows 8 blue screen error while building my wcf service. I tried all suggestions above.. but it didn't solve the problem.

Lastly, I removed and recreated the new application from IIS on the same wcf project.
Then every thing works fine.

T3 H40
  • 2,326
  • 8
  • 32
  • 43
agit
  • 631
  • 5
  • 17
0

Quoting this SO answer:

This can happen while referencing COM wrapper dlls.

Go in your Visual Studio Project, under References, select the referenced COM wrapper assemblies, right click, preferences, and make sure that Embed Interop Types and Specific Version are both set to False.

alelom
  • 2,130
  • 3
  • 26
  • 38
0

@Ernest 's answer worked for me on Visual Studio 2022

On Visual Studio 2019 I was able to fix this manually deleting the ".vs" folder into the solution directory.

Doht
  • 1
  • 1
  • 1
0

In my case, this issue was caused by the path length limit in Windows 10. I didn't find any temporary files to delete anywhere. This issue was resolved for me only when i moved my project to a directory with a shorter path length. I'm using Microsoft Visual Studio 2022.

ahiyantra
  • 1
  • 2
  • 4