Could not load file or assembly … The parameter is incorrect … HRESULT: 0x80070057 (E_INVALIDARG)
I've just had my machine upgraded at work. We can't see anything that's changed, except now when I try to build the website project I'm working on (in Visual Studio 2005), I get an error:
Could not load file or assembly 'uSwitch.Web.UI.Lego, Version=1.0.2405.17351, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
The assembly name is the main assembly I'm working on and the version number is the current version created by Visual Studio's autoincrement. The file has correctly been copied to the web project's bin folder and I can open it up in Lutz Roeder's .Net Reflector and see everything I'd expect to see, including recent changes to the codebase.
I've deleted the version in the .Net cache, inside C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\ and that appears to make no difference. I get the same problem when trying to run a web project in either IIS or Cassini (VS2005's in-built webserver), indeed it doesn't get as far as initialising Cassini.
Google isn't finding me anything useful; does anyone here have any ideas?
Please copy all replies to owenblacker at uswitch dot com, in case I miss them here.
Thanks for your help, everyone!
Owen
Answers
Reinstall .NET? Nah. I didn't even have to clean up the entire Temp Files directory. I deleted the directory C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\MyWebService and recompiled and it worked fine.
I suspect that there is a conflict between compiled code versions that happens here. The web service I was building worked fine until I went to debug some code that I had added. I changed the web.config debug option to 'true' and immediately got the 'parameter is incorrect' error. I suspect that the compiler doesn't rebuild every file when you change just the web.config like it does when you change the Solution Configurations dropdown (up in the menubar).
Just some guesses.
Okay...I've figured out my issue. I'm not for sure why uninstalling and reinstalling worked for people. Unless, they somehow messed up the web.config in the C:\windows\Microsoft.NET\Framework\v2.05027\Config\ directory.
Background: The assembly causing me trouble was built in house and I did not have the source code.
Required: You need the Visual Studio SDK for ildasm.exe
Steps:
1.) Disassemble the .dll with the command ildasm.exe AssemblyName.dll /out:AssemblyName.il
2.) Open the newly created AssemblyName.il with a text editor and search for "permissionset"
3.) Find and delete the following lines:
.permissionset reqmin
= {[mscorlib]System.Security.Permissions.PermissionSetAttri bute = {property string 'Name' = string('nobody')},
[mscorlib]System.Security.Permissions.SecurityPermission Attribute = {property bool 'Execution' = bool(true)}} 4.) Save and rebuild the assembly with the following command: ilasm.exe AssemblyName.il /dll
5.) Throw the new dll in your bin directory or if it's strong named and needed in the GAC you can put it there.
Hope that helps.
All Replies
If it's of any help, if I right-click | View in Browser, rather than building or debugging, I get the following stack trace:
[ArgumentException: Unable to generate permission set; input XML may be malformed.]
System.Security.PermissionSet.CreateSerialized(Object[] attrs, Boolean serialize, Byte[]& nonCasBlob, PermissionSet& casPset, HostProtectionResource fullTrustOnlyResources) +2747750
[FileLoadException: Could not load file or assembly 'uSwitch.Web.UI.Lego, Version=1.0.2405.17351, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))]
System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +211
System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +141
System.Reflection.Assembly.Load(String assemblyString) +25
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +32
[ConfigurationErrorsException: Could not load file or assembly 'uSwitch.Web.UI.Lego, Version=1.0.2405.17351, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +580
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +203
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +45
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
System.Web.Compilation.WebDirectoryBatchCompiler..ctor(VirtualDirectory vdir) +199
System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(VirtualDirectory vdir, Boolean ignoreErrors) +37
System.Web.Compilation.BuildManager.BatchCompileWebDirectory(VirtualDirectory vdir, VirtualPath virtualDir, Boolean ignoreErrors) +445
System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +77
System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +596
System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +76
System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +86
System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +42
System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +32
System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +62
System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +294
System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +139
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +146Uninstall, reboot, then install all parts of the .net framework - I had the same problem after my laptop's battery unexpectedly gave-up. The only thing that helped was full reinstall of .net.
Hope this works for you too,
Miroslav B.
- Unmarked As Answer byOwen Blacker Monday, July 28, 2008 5:03 PM
- A colleague found (this afternoon) that that worked for him too. I was pretty sure we’d tried that already, but evidently not.
Thanks, Miroslav. I’m glad it fixed the problem for you and hopefully it won’t be a problem for anyone again :o) - I'm sure that works great, but I wouldn't call it a solution. What is causing this error? I'm digging a little further. I'll post what I find.
Okay...I've figured out my issue. I'm not for sure why uninstalling and reinstalling worked for people. Unless, they somehow messed up the web.config in the C:\windows\Microsoft.NET\Framework\v2.05027\Config\ directory.
Background: The assembly causing me trouble was built in house and I did not have the source code.
Required: You need the Visual Studio SDK for ildasm.exe
Steps:
1.) Disassemble the .dll with the command ildasm.exe AssemblyName.dll /out:AssemblyName.il
2.) Open the newly created AssemblyName.il with a text editor and search for "permissionset"
3.) Find and delete the following lines:
.permissionset reqmin
= {[mscorlib]System.Security.Permissions.PermissionSetAttri bute = {property string 'Name' = string('nobody')},
[mscorlib]System.Security.Permissions.SecurityPermission Attribute = {property bool 'Execution' = bool(true)}} 4.) Save and rebuild the assembly with the following command: ilasm.exe AssemblyName.il /dll
5.) Throw the new dll in your bin directory or if it's strong named and needed in the GAC you can put it there.
Hope that helps.
One of my colleagues found something similar a few months back; I asked him to post it here, but hadn't realised he'd not done so:
-
Uninstall .NET (Runtime and SDK)
-
Uninstall IIS
-
Install .NET (Runtime and SDK)
-
Install IIS
This seemed to fix the problem for him, without the rather-more-drastic course of a full machine rebuild.
I hope this helps people!
- Unmarked As Answer byOwen Blacker Monday, July 28, 2008 5:02 PM
- Unmarked As Answer byOwen Blacker Monday, July 28, 2008 5:01 PM
- Unmarked As Answer byOwen Blacker Monday, July 28, 2008 5:01 PM
- Unmarked As Answer byOwen Blacker Monday, July 28, 2008 5:01 PM
- Unmarked As Answer byOwen Blacker Monday, July 28, 2008 5:01 PM
-
- http://forums.asp.net/p/1125637/1769670.aspx
worked for me too, cleaned up C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files and shazzaam- Unmarked As Answer byOwen Blacker Monday, July 28, 2008 5:02 PM
It worked for me too. I cleaned up the C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files and I was happy again
.
Hello ppl.
Ok, that's not working for me.
I recently made a Conversion from VS2003 to VS2005.
I was using a reference to a DLL working very well in VS2003. In VS2005 it gives-me this message:
Error 122 Não foi possível carregar o ficheiro ou assemblagem 'CAPICOM, Version=2.1.0.0, Culture=neutral, PublicKeyToken=112d456261246b54' ou uma das respectivas dependências. O parâmetro é incorrecto. (Excepção de HRESULT: 0x80070057 (E_INVALIDARG))
(sorry for the portuguese message) it basically says:
Error 122 It was not possible to load the file or assembly 'CAPICOM ...' or one of its dependencies. The parameter is incorrect. (exception HRESULT .... )Thata DLL is external and protected. i cannot access it.
any ideas?
thanks...
Reinstall .NET? Nah. I didn't even have to clean up the entire Temp Files directory. I deleted the directory C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\MyWebService and recompiled and it worked fine.
I suspect that there is a conflict between compiled code versions that happens here. The web service I was building worked fine until I went to debug some code that I had added. I changed the web.config debug option to 'true' and immediately got the 'parameter is incorrect' error. I suspect that the compiler doesn't rebuild every file when you change just the web.config like it does when you change the Solution Configurations dropdown (up in the menubar).
Just some guesses.
I got this exact same error as well.
Some people have suggested to unistall .NET Framework and install .NET Framework. Does that .NET FRamework comes from VB 2005? IF so does that mean I have to reinstall VB 2005?
I am working w/VB 2005 and I ran into the error.
Any suggestions? And does anyone know what this error means and why I am getting it?
~M~
Hi LatinaCWU21,
you can first try http://forums.asp.net/p/1125637/1769670.aspx - clean up C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files
If this doesn't help, try reinstalling .NET Framework. VB 2005 is based on .NET Framework 2.0, but you can reinstall .NET without uninstalling VB. You can find the .NET 2.0 setup file (called dotnetfx.exe) and it will allow you to reinstall .NET.
Hope this helps,
Kirill
Another thumb UP;
I deleted the entire folder of Temporary Internet Files and it worked for me.
Yes, Really, re-installing .NET is not the solution. Glad that this worked
Kirill,
I tried repairing .NET FRAMEWORK 2.0, but i still got the error message:
The parameter is incorrect … HRESULT: 0x80070057 (E_INVALIDARG)
I found out that it goes away when I comment out :
'<Assembly: PermissionSetAttribute(SecurityAction.RequestMinimum, Name:="Local Intranet")>
'<Assembly: PermissionSetAttribute(SecurityAction.RequestOptional, Unrestricted:=True)>
Does anyone know why?
BUT now I get a different error when I comment out the Assemblies:
Current error now:
A first chance exception of type 'System.Security.SecurityException' occurred in mscorlib.dll
(There was an error: Request for the permission of type "System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture= neutral, PublickKeyToken=b77a5c561934e089 failed.)
Help, does anyone know what to do? And why I get it when I comment out the 2 assemblies listed?
Have you tried clearing the temporary files as described above?
I also recommend re-reading this thread as it contains a lot of useful information.
- Note that on 64-bit Windows, the path you need to clear is:
%windir%\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files - For the purpose of easier and quicker debugging and rebuilding, VS always caches the assemblies and compiled files in it's temporary asp.net files. you can find a folder for each and every project you run.
As far I have noticed, this problem normally occurs when there was an unexpected crash of VS or the application. whenever your run an application, VS checks whether the binaries are up to date by checking it's signature, attributes etc (if auto update is enabled). There are chances when the application might crash writing down the signature and attributes of a binary the correct one but the contents would not be perfect. At this point we get this error.
Mostly we developers goto the temporary files and find the particular project and delete it; which would be the simple solution without digging much
To delete temporary files worked for us.
Regards!
- Excellent Solution, thanks a lot guys!!!! It worked very good for me!!
- Visit at http://www.ginkostyle.blogspot.com/ for the answer its work
- I have had this issue many times. The key is to follow these steps strictly...
Delete the contents of C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\
Delete the dll from the bin directory.
Recompile and get a "FileNotFoundException" on execution to confirm the dll is gone.
Copy the dll back to the bin directory.
Recompile
All is now well
I feel as if I am giving a recipe for a witches brew to a 12th century alchemist instead of a rational set of operations to a rational man, but, there it is.
If this DOES NOT solve the problem for anyone, please let me know. I will be curious.
Best,
Brett
bnieland Okay...I've figured out my issue. I'm not for sure why uninstalling and reinstalling worked for people. Unless, they somehow messed up the web.config in the C:\windows\Microsoft.NET\Framework\v2.05027\Config\ directory.
Background: The assembly causing me trouble was built in house and I did not have the source code.
Required: You need the Visual Studio SDK for ildasm.exe
Steps:
1.) Disassemble the .dll with the command ildasm.exe AssemblyName.dll /out:AssemblyName.il
2.) Open the newly created AssemblyName.il with a text editor and search for "permissionset"
3.) Find and delete the following lines:
.permissionset reqmin
= {[mscorlib]System.Security.Permissions.PermissionSetAttribute = {property string 'Name' = string('nobody')},
[mscorlib]System.Security.Permissions.SecurityPermissionAttribute = {property bool 'Execution' = bool(true)}}4.) Save and rebuild the assembly with the following command: ilasm.exe AssemblyName.il /dll
5.) Throw the new dll in your bin directory or if it's strong named and needed in the GAC you can put it there.
Hope that helps.
If it's of any help, if I right-click | View in Browser, rather than building or debugging, I get the following stack trace:
[ArgumentException: Unable to generate permission set; input XML may be malformed.]
System.Security.PermissionSet.CreateSerialized(Object[] attrs, Boolean serialize, Byte[]& nonCasBlob, PermissionSet& casPset, HostProtectionResource fullTrustOnlyResources) +2747750
[FileLoadException: Could not load file or assembly 'uSwitch.Web.UI.Lego, Version=1.0.2405.17351, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))]
System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +211
System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +141
System.Reflection.Assembly.Load(String assemblyString) +25
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +32
[ConfigurationErrorsException: Could not load file or assembly 'uSwitch.Web.UI.Lego, Version=1.0.2405.17351, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +580
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +203
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +45
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
System.Web.Compilation.WebDirectoryBatchCompiler..ctor(VirtualDirectory vdir) +199
System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(VirtualDirectory vdir, Boolean ignoreErrors) +37
System.Web.Compilation.BuildManager.BatchCompileWebDirectory(VirtualDirectory vdir, VirtualPath virtualDir, Boolean ignoreErrors) +445
System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +77
System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +596
System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +76
System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +86
System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +42
System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +32
System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +62
System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +294
System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +139
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +146- I have the same problem and delete temporary files not solve.when I take out one dll of the site give the same error with other.I don't know what to do, the problem only occurs in the server that is windows 2003, I can't uninstall .net because other sites are running in the same serverin local machine works file.I need helpthanks,SC
Sérgio Carvalho - Clearing the temp folder solvved it for me. Thanks for the time saver.


