Exception from HRESULT: 0x80070057 (E_INVALIDARG) - c#

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.

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

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\

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

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.

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.

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.

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.

#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.

Related

Compilation Error: The type or namespace name could not be found

To start, I have read tons of questions like this but nothing has fixed my issue. When I publish my project from Visual Studio 2013 to a server, I get the following error:
Its apparently missing a reference to a library I'm using. The issue is the dll is getting published (it is in the bin folder on the server). It seems its having some issue finding the reference? I've tried copying the dll and putting it in the same directory as the c sharp code. I've made sure everything is using the same framework. I have no idea what's happening. I need some help. Thanks in advance!
Here is the bin folder:
Here is the folder on the server:
As you can see the project is very small right now.
Here is the Default.aspx code:
Here is the C# code (Default.aspx.cs):
And here is my web.config:
It is because the DbAccess dll is not getting the path
you need to make a folder in your solution and give any name like "ThirdpartyDll".
Paste your dll in this folder and while adding new dll give reference path from this folder and then publish.
On server application will take the same path, which i think you had given from local.
I made the mistake of not formatting the directory on my server using IIS. If anyone comes across this make sure you do that!!!

C# Web Api/ MVC.net not loading assemblies properly

I'm new to C# and .net in general, and I need to use it to work with the SDK for a major piece of software we use.
I can add the assemblies they tell me to add in a console application and everything works fine. When I try to add them to any web application (either MVC or WebAPI), I keep getting errors saying other assemblies are missing. Eventually I just added every assembly/reference (not sure the correct term for this, pretty much just .dll files) in the sdk folder and now it is working. This definitely cannot be the correct way to do this.
Is there something I am missing that allows assemblies/references to load other assemblies/references, or is something else the cause of my issue?
UPDATE:
The exceptions are usually something like this:
Could not load file or assembly 'Server, Version=1.5.1.0, Culture=neutral, PublicKeyToken=d11ef57bba4acf91' or one of its dependencies. The system cannot find the file specified.
And it does not occur during build, only when the function is actually being called from the web application( in my case, since it's an api, when I visit the URL that returns my JSON data)
You can use a tool called "IL Disassembler" that is installed along with Visual Studio to see what other dependencies the SDK's Assembly depends on.
The install location may vary but mine is here...
"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\ildasm.exe"
Drag and drop the SDK's assembly that you are using onto the tool and click the manifest field. A dialog will open with the other assemblies that you'll need to include.
If your console application works but the web application does not then the exception should specify which assembly is missing.
Compare you console output directory with the output directory of you web build. Make sure the dll that is required is being deployed to the web directory you are running.
In visual studio with your web project find the assembly under references and select it. Make sure that the property "Copy Local" is set to TRUE.

Publish site via visual studio 2013

I try to publish a site to: http://lolacyclingclub.org/ , but I get this error:
Error 2 Copying file bin\DotNetOpenAuth.AspNet.xml to obj\Release\Package\PackageTmp\bin\DotNetOpenAuth.AspNet.xml failed. Could not find file 'bin\DotNetOpenAuth.AspNet.xml'. 0 0 Lolabike
What exactly you have to do?
I found something that I have to delete the bin folder? Is that correct because it seems strange?
I see now this error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator to inform of the time the error occurred and of anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Web Server at lolacyclingclub.org
I dont know this error. has it to do read/write permissions? Or something like that?
I had similar problem. I referenced some libraries (which had reference to another libraries) in my ASP.NET web application. Unfortunately after project rebuild dll's which were previously copied to bin folder were deleted. This caused publish problem very similar to your problem. Solution was to copy all needed files to bin folder. I guess you need to put your files back to bin folder and it will publish successfully.
Deleting bin folder is not an option - these files are needed;)

System.IO.FileNotFoundException Reference not found on when run on users computer

I am making a program in C# with Visual Studio Express 2013. I am using Ionic.zip (dotnetzip). When i run it from the .../bin/release directory or from Visual studio, it runs perfectly fine. when the end user has it on their computers, or I run it from another location, when it tries to perform an action using ionic.zip, it crashes with the following exception
System.IO.FileNotFoundException: Could not load file or assembly 'Ionic.Zip, Version=1.9.1.8, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c' or one of its dependencies. The system cannot find the file specified.
File name: 'Ionic.Zip, Version=1.9.1.8, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c'
I have absolutely no idea how to fix this, and have been researching for the last 3 days how to with no success. Any help will be appreciated.
Thanks,
James
CHeck dependencies - either directly, or possibly a not installed framework reference. If the assemblz is in the search paths if should be found.
You need to have an installer or script copy the DLL to the executing directory(where the executable is) or into the computers PATH.
First include that file in your resources after that in its properties:
Select Build Action -> Content
Copy to Output Directory -> Copy if newer
I am attaching a picture. Now you can access its correct path as follows:
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\Resources\\yourfile.exe";

checkin code to subversion from Visual studio 2008 where directory folders at same level solution file is at

I am using the current version of anksvn. I can add a C# 2008 console application successfully to subversion. I can also download the C# 2008 code to my workstation as a working copy. However the problem is the application does not compile clean. I am getting the error message, "missing directive or an assembly reference" on alot of the members.
I know there has to be some kind of a problem when I add this soltuion to
anksvn. Note: I can load all the other soltuion files to anksvn and I do not
have problems.
What is occuring is the 3 other project files that I am working with are at
the same directory level where the solution file is located at. One of the 3
project files that I am referring to has its own visual studio 2008 solution also.
I believe most other solution files have their project files in a directory
path level that is lower than the solution file.
One thing I have tried was to open up the solution file and change the
directory paths where the 3 files are located at. This did not help.
Thus can you tell what I can do when I check in this file to anksvn, so that it
will compile clean once I have checked it oout of anksvn?

Categories

Resources