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";
Related
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.
I added a solution to my project, just for unit tests (NUnit)
I have included references to all of the dlls the test solution needs
but..
I am getting the following file not found error:
System.IO.FileNotFoundException: Could not load file or assembly '\bin\Debug\bin\aLibrary.dll' or one of its dependencies. The system cannot find the file specified.
The issue is that on build, all of my dlls are correctly getting placed into
MySolution/bin/Debug , which is what I have the path set to in the project properties, but the error is telling me that the application is looking in MySolution/bin/Debug/bin
The solution settings show the correct path
If I copy those dll files from MySolution/bin/Debug to MySolution/bin/Debug/bin all works as expected.
Question
I have no idea where the path is being set. How do I correct or where should I look? Any ideas are welcome.
Thanks
Thanks
Right click on the project, go to properties, reference paths and check if you need to change the path: more described here: https://msdn.microsoft.com/en-us/library/ayds71se(v=vs.120).aspx
I have developed a simple .EXE in Visual Studio 2015, which adds an item to the specified SharePoint site and List when the user runs some process.
The file is saved in a shared network drive, and everything seems to work perfectly except for one detail.
I can't seem to work out how to run the EXE without having the following .dll files saved in the same folder:
Microsoft.SharePoint.Client.Runtime.dll
Microsoft.SharePoint.Client.dll
If I move these from the folder in which the EXE is saved in, I get this error message when running the exe:
Unhandled Exception: System.IO.FileNotFoundException: Couldt not load file or assembly 'Microsoft.SharePoint.Client, Version=15.0.0.0, Culture=neutral ... Or one of its dependencies ...
I (think) I have set up 'strong named assembly' by following these instructions in VS for the app, and I was able to add the SharePoint dlls to the GAC by using the VS command line and gacutil.exe (with a successful confirmation message), but I am still unable to run the EXE without having the 2 .dll files present.
Note: I developed the app to target .NET-4, but the users will be accessing the files from a system with .NET-3.5 installed, however the server on which the EXE is saved on does have the .NET-4 environment.
I was able to achieve this by using a tool called ILMerge which can be found here and is available as a NuGet package.
ILMerge allows you to merge dlls and exe files into a single exe
My C# application runs fine (in both Debug and Release mode) when I run it through Visual Studio 2012 or executing the .exe through Debug/Release folder, but it fails when I copy that .exe to some other location and run it. The error message that I receive is:
Could not load file or assembly 'bms.Common, Version=5.0.0.1006, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
I am copying the .exe from Debug/Release folder to some folder. Am I doing it wrong?
In Debug folder exists only .exe file? No other dlls? You should copy all .dll files from Debug folder to target directory along with .exe file.
If you want package all libraries into one executable assembly then look at ILMerge utility http://www.microsoft.com/en-us/download/details.aspx?id=17630
usage:
C:\Program Files (x86)\Microsoft\ILMerge>ilmerge C:\my.exe C:\my.dll /out:C:\merged.exe
Generally speaking, you should be deploying the DLLs in the same folder as the executable. With .NET we don't usually compile everything into one big .exe the same way you might link a c program.
There are certain exceptions: for example, you could put the DLLs in the GAC or put them somewhere else and provide what is known as a "probing path." Those are advanced approaches which should not be used unless you know what you're doing.
For complete information on how .NET resolves DLL references, I suggest you read here.
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.