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

Could not load file or assembly … The parameter is incorrect … HRESULT: 0x80070057 (E_INVALIDARG)
polska2180
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
Quirk
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:
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.
ramanmahalingam
worked for me too, cleaned up C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files and shazzaam
Krutika
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:
This seemed to fix the problem for him, without the rather-more-drastic course of a full machine rebuild.
I hope this helps people!
kasmatt2000
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
Hollispj
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 Nao foi possivel carregar o ficheiro ou assemblagem 'CAPICOM, Version=2.1.0.0, Culture=neutral, PublicKeyToken=112d456261246b54' ou uma das respectivas dependencias. O parametro e incorrecto. (Excepcao 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...
leovernazza
Uninstall, 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.
eagarwal
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
.
yeos_lee
Thanks, Miroslav. I’m glad it fixed the problem for you and hopefully it won’t be a problem for anyone again :o)
Pinkcess
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.
ZeePrime
ChaosBlade
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
baga
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~
grassgrassgrass
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