I am following a course on PluralSight on C# Fundamentals all is going well until I try to debug the application inside visual studio or even run without debug I get the exception below. Even with simple Hello World I get this exception also. So far I have tried reinstalling Visual Studio the problem occurs again, also to mention I create the folder structure through the terminal I am not sure this is relevant but better to mention it.
I am using Visual Studio Version Version 16.4.2.
The runtime error:
An handled exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module. Could not load file or assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot fund the file specified.
The code:
using System;
namespace Gradebook
{
class Program
{
static void Main(string args[])
{
Console.WriteLine($"Hello, {args[0]}!");
}
}
}
In case anyone else has this issue, I am also going through the same course. The issue is that when you create the file through the command line, you don't have a solution file created. So then, I thought maybe I could select "Open a local folder" in the visual studio menu, navigate to Program.cs and execute it from there. If you try to do that, you will get this error
Instead, you need to click "Open a project or solution". Notice that it lets you open a project file in addition to the solution. So even though you don't have a solution (.sln) file, you can click on the .csproj file. Then after doing so, you will be able to directly run the code in visual studio. Also, it will automatically create a solution file.
Posting this as answer so I can add screenshots.
Increase Framework Version to 4.5. To do so, you need to enter project properties. You get there by e.g. right clicking your Project => Properties or by double clicking "Properties" in your solution explorer:
The Application tab should be the first tab. There you find a dropdown with which you can specify your Target Framework version:
While you are in your project's properties, you might as well provide default command line arguments to prevent said "IndexOutOfRange" error in debug:
I installed VS.2017 Enterprise and start a web performance project. When I try to add a Web performance test to the project I receive the error:
"The Web test could not be loaded: Could not load the type
'Microsoft.VisualStudio.TestTools.WebTesting.SharepointInformation'
from assembly 'Microsoft.VisualStudio.QualityTools.WebTestFramework'
Version=10.0.0.0, .."
TL;DR:
Check installed prerequisites in the latter part of Create a web performance and load test project
In my case, replacing original file
C:\windows\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.WebTestFramework\10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.QualityTools.WebTestFramework.dll
with
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ReferenceAssemblies\v4.0\Microsoft.VisualStudio.QualityTools.WebTestFramework.dll solved the problem.
I tackled the same issue. Every time I created Web Performance and Load Test Project in Visual Studio 2017 Enterprise (with arbitrary .NET framework version) I got the same error when I tried to open *.webtest file. VS's user interface seemed incomplete and clicking on toolbars sometimes shown null exceptions.
At first, I thought I have incomplete installation, according to Create a web performance and load test project. I have even tried to completely uninstall and reinstall mentioned packages. Unfortunately, this did not help. I have also experimented with adding and removing reference to Microsoft.VisualStudio.QualityTools.WebTestFramework as there are several options in my reference browser, but without success.
There is not much information about WebTesting.SharepointInformation namespace. After a while, I discovered the existence of Microsoft.VisualStudio.QualityTools.WebTest.SharePoint.dll and after closer inspection, I have noticed that it references QualityTools.WebTestFramework assembly in C:\Windows\assembly\... that has the same assembly version and public key token, yet smaller in size compared to the one that is contained in VS 2017 installation. I have replaced it with VS2017's one and voila, *.webtest can be successfully opened.
The above answer is correct but the problem is the directory isn't accessible in my case due to some reasons so I just open my cmd and run this command. Just run, it will copy the file, but first turn of the vs.
copy "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ReferenceAssemblies\v4.0\Microsoft.VisualStudio.QualityTools.WebTestFramework.dll" "C:\windows\assembly\GAC_MSIL\Microsoft.VisualStudio.QualityTools.WebTestFramework\10.0.0.0__b03f5f7f11d50a3a"
I'm converting a project to the new unified api from Xamarin. I've converted all my methods and project settings. But when I run the project in debug I'm getting the following error message when building my project:
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets: error : Failed to load output manifest for actool for the file obj/iPhone/Debug FT/actool/asset-manifest.plist: Argument is out of range. Parameter name: index
Currently working with Xamarin Studio version 5.7 (build 660) and Xamarin.iOS version 8.6.0.41.
Did someone already fixed this problem? If so how?
Finally I found a solution.
In iOS8 Apple changed something that requires the Asset Catalog to be used for images.
So I created an asset catalog for my Launch images and icon images and my project was building without errors.
I didn't faced this problem but I saw some people talking about this and there are 2 possible solution (known to me),
First is to clean the project and re run.
another is manually installing latest Xamarin installer
Several years before I started working at this job another developer who is no longer here wrote an application in classic ASP using HTML, vbscript and javascript. This is fine but the problem is that 2 pages were written in C# with an HTML file and a code behind file. There was no solution files for these two pages. They may have been originally created in Visual Studio but they don't exist in it now.
That is important because there is a lot of things that Visual Studio just does for you without even thinking.
My problem is that in these two C# pages I need to get them to reference a DLL. This is a simple task when using Visual Studio. You just add a reference to the project and life is good. But outside of VS nothing seems to work.
I tried putting the dll in the same folder as the pages and then I tried the following:
Using myDLL;
myDLL dll = new myDLL();
myDLL dll = myDLL();
I found some code online that said to create an internal static class and use [DLLImport()] but that didn't work either. It couldn't find the dll or the Entry Point for the dll. I am currently researching how to create an entry point, just in case this is the method to make everything work.
Outside of having to rewrite these pages in vbscript (which I don't have the time to do) I am at a loss.
Has anyone ran into this problem before? Is there something that I can put in the web.Config? Or is this just impossible and I am hosed.
BTW this is all running under the 2.0 .net framework.
If you drop the DLL you want the code to reference into the bin folder of the website, then open the web.config and locate the following section configuration -> system.web -> compilation -> assemblies.
You need to add the display name of the assembly to that list - so that the compiler will reference that assembly during it's late-bound build process.
Now you should be able to use the stuff that's in it on those pages.
If you don't the know the display name of the assembly (typically yourassembly, version=*.*.*.*, Culture=neutral, PublicKeyToken=null for culture-invariant, non-strong-named assemblies) you can open it in a tool like ILSpy (there are others, it's just become my favourite) and it tells you when you select it in it's UI:
sorry for the poor highlighting - jerky hand following far too much coffee
If all the code in that assembly is in a single namespace, also, you can also add a default using to all the .cs or .aspx code in the project by adding that namespace to configuration -> system.web -> pages -> namespaces - making it simpler to use that code in the pages.
I created a VS Solution/Project for my app. I compiled and published it to the web server. When I published it I had it copy all project files.
I ran it and it crashed because it could not find my dll.
I tried adding the lines that Andras mentioned above and it seemed like it was getting me closer but it only changed the errors I was getting.
Then I went into IIS on the web server. I expanded the folder listing under Web Site. I right clicked on the folder that contained my app and made that folder into an application folder.
After I did that everything just worked. So then I thought I would see what happened if I backed out all of the additional code I added to my C# app and the Web.Config file. It still worked. All I needed to do was to make the folder an application folder in IIS and put a Using statement in my C# app and life is wonderful again.
Thanks for all the comments and suggestion. Andras thanks for the link to ILSpy. That is a cool little tool.
Take care,
Robert
I agree with Jon, it sounds like you should try creating a new project for these files. It's always better to leave code better off than you found it. If a new project is not an option for some reason, you should indicate this in your question.
Recently I met the following exception at C# solution:
Error 2 Could not load file or assembly 'Newtonsoft.Json,
Version=3.5.0.0, Culture=neutral, PublicKeyToken=b9a188c8922137c6' or
one of its dependencies. The parameter is incorrect. (Exception from
HRESULT: 0x80070057 (E_INVALIDARG))
This does not depend either on my code or on the name of assembly (like Newtonsoft.Json in this case).
When I delete this dll from the solution the compiler tells about another in the same exception. So I suppose something shoud be turned off/on at my PC :)
Looks like a corrupted assembly being referenced.
Clear both:
the \bin folder of your project
the temp folder (should be C:\Users\your_username\AppData\Local\Temp\Temporary ASP.NET Files in windows 7)
and see if the error still happens
Depending on if your are running X64 you might need to clean up a couple more spots. Just cleaning up my user directory was not enough.
%TEMP%\Temporary ASP.NET Files
C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files
This list will grow as if you have other versions of the framework installed.
I had to clear
C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files
Only then did the issue get resolved.
To know what to clear for sure - add the following registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion\EnableLog (DWord set to 1).
Then you will see output like below. This tells you where asp.net is attempting to load your DLLs. Clear this directory.
LOG: This bind starts in default load context.
LOG: Using application configuration file: c:\app\AtlasAdvisor\web\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL **file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/3c8629f7/dfa387b6/Avanade.ViddlerNet.DLL.**
LOG: Attempting download of new URL **file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/3c8629f7/dfa387b6/Avanade.ViddlerNet/Avanade.ViddlerNet.DLL**.
Clear out the temporary framework files for your project in:-
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\
You can also clear the packages directory and allow NuGet to re-download missing packages
it solved the issue for me
Delete all files from these folders .
C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files
C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET
Files
Getting fresh set of binaries from Source control helped.
Thanks
Just clear this folder: (only windows x64)
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files
Thanks Alex your second point helped me fix this.
It appears that unless you run visual studio as an administrator in Windows 7 it stores your temp files locally rather than C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files.
See following blog post: http://www.dotnetscraps.com/dotnetscraps/post/Location-of-Temporary-ASPNET-files-in-Vista-or-Windows-7.aspx
I had the same issue here - above solutions didn't work. Problem was with ActionMailer. I ran the following uninstall and install nuget commands
uninstall-package ActionMailer
install-package ActionMailer
Resolved my problems, hopefully will help someone else.
This can happen while referencing COM wrapper dlls. Within your Visual Studio Project, under References, select the COM wrapper dlls being referenced and ensure they have the the following property values: "Embed Interop Types": False and "Specific Version": False.
I just delete my application temp data from this path
C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files
Problem resolve
I see lot of techies have posted about clearing temporary directories of ASP .Net run-time pertaining to each and every .Net framework hosted on your machine as in this answer. But I believe we should know the clear-cut logistics as to why we need to blindly clear all of temporary working directories of all .Net frameworks. According to me, it should not be the case.
My advice would be that you should try a pin pointed directory clearing approach to resolve this issue. How would you know which directory to clear?
Go to IIS and right click on your website node in left navigation pane to open the context menu. In the context menu point to Manage Application -> Advanced Settings... to open the Advanced Settings window.
Check the Application Pool your website is assigned to. In my case it is DefaultAppPool as shown below:
Now go to Application Pools node in left navigation bar in the IIS. Now check that which .Net CLR Version is being run by your app pool. In my case it is v4.0 as shown below:
Since the CLR version being hosted by my app pool is v4.0, so I prcisely cleared only the temporary files in the folder pertaining to ASP .NET v4.0 only as below:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files
And that's it. My problem got resolved.
Lesson learnt: This is indicative of the fact that all the temporary files being used by your website aren't scattered across several directories but they are at once place being referred by your app pool. So you need to clear that specific folder only.
Clearing C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files worked for me. Thinking of automating the deletion process to avoid the issue in future.
If you are using SQL Server 2012's Data Tools, which uses the VS2010 shell as at May 1 2013, check your Configuration Manager settings. A server name change from Workflow to xCPWorkflow was enough to produce the exact same The parameter is incorrect (Exception from HRESULT: 0x80070057 (E_INVALIDARG)) message.
You can either clean, build or rebuild your application or simply delete Temporary ASP.NET Files at C:\Users\YOUR USERNAME\AppData\Local\Temp
This works like magic. In my case i had an assembly binding issue saying Could not load file bla bla bla
you can also see solution 2 as http://www.codeproject.com/Articles/663453/Understanding-Clean-Build-and-Rebuild-in-Visual-St
I had this problem when making controller in MVC. I changed version .net framework. The problem was solved
The problem relates to the .Net runtime version of a referenced class library (expaned references, select the library and check the "Runtime Version". I had a problem with Antlr3.Runtime, after upgrading my visual studio project to v4.5. I used NuGet to uninstall Microsoft ASP.NET Web Optimisation Framework (due to a chain of dependencies that prevented me from uninstalling Antlr3 directly)
I then used NuGet to reinstall the Microsoft ASP.NET Web Optimisation Framework. This reinstalled the correct runtime versions.
In my case i wanted to compile a COM visible DLL. The problem was that an older version of this DLL was located here:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE
Thus Visual Studio loaded this version instead of the newly compiled one, as it tried to register it.
Clear all files from temporary folder (C:\Users\user_name\AppData\Local\Temp\Temporary ASP.NET Files\project folder)
Sometimes you, also, need to clean this folder: C:\Windows\Temp\Temporary ASP.NET
I faced same error because application didn't find dependent frameworks in C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\ folder. I just repair my Visual studio which added required framework in above location and it working fine.
In my case, changing the IISExpress port number in my project properties, solved the problem.
If anyone else out there is using the WiX toolset, I discovered that my installer project had a reference to an old project that had recently been removed from the solution. Took me a while to realize since there are a number of projects in the solution I was attempting to build and the message did not indicate which project was failing to build (and clean, which was failing as well).
I had users of Siemens Teamcenter 10 Client for Microsoft Office getting the same error about a different DLL. None of the other answers worked. The solution was to delete the folders in
C:\Users\%username%\AppData\Local\assembly\
I Had the similar issue while opening Nuget Packet manager,
I removed all the temp files and build the project, it worked fine.
I had the same issue with "Chocolatey Server (Simple)" running on IIS and had to do the following steps
Clean the "C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files" as recommended
Uninstall the "Chocolatey Server (Simple)" application via choco
Remove the directory "C:\tools\chocolatey.server" from the chocolatey package directory. Important, because otherwise Web.config is holding old dependencies which leads to the error. A simple re-installation will not update an existing Web.config (as it was in my case).
Restart IIS and config Chocolatey Server as recommended by the authors. The chocolatey server page should now be visible without any errors.