Could not load file or assembly 'ClearScriptV8.win-x64.dll' or one of its dependencies. The module was expected to contain an assembly manifest - clearscript

I have .NET MVC app (.NET Framework 4.6.1) and I want to add ClearScript to my app.
I've added package Microsoft.ClearScript via NuGet and after launch app I have error:
Could not load file or assembly 'file:///D:\PathToProject\bin\ClearScriptV8.win-x64.dll' or one of its dependencies. The module was expected to contain an assembly manifest.
This file is in bin folder
What am I doing wrong? And how can I resolve this issue?
UPDATE
The next step I did removing assemblies into web.config files as #BitCortex advised:
<system.web>
<compilation>
<assemblies>
<remove assembly="ClearScriptV8.win-x64" />
<remove assembly="ClearScriptV8.win-x86" />
</assemblies>
</compilation>
</system.web>
but it didn't help.
In the result I've comment out these strings into .csproj file:
<Import Project="..\packages\Microsoft.ClearScript.V8.Native.win-x86.7.2.5\build\Microsoft.ClearScript.V8.Native.win-x86.props" Condition="Exists('..\packages\Microsoft.ClearScript.V8.Native.win-x86.7.2.5\build\Microsoft.ClearScript.V8.Native.win-x86.props')" />
<Import Project="..\packages\Microsoft.ClearScript.V8.Native.win-x64.7.2.5\build\Microsoft.ClearScript.V8.Native.win-x64.props" Condition="Exists('..\packages\Microsoft.ClearScript.V8.Native.win-x64.7.2.5\build\Microsoft.ClearScript.V8.Native.win-x64.props')" />
<Import Project="..\packages\Microsoft.ClearScript.V8.ICUData.7.2.5\build\Microsoft.ClearScript.V8.ICUData.props" Condition="Exists('..\packages\Microsoft.ClearScript.V8.ICUData.7.2.5\build\Microsoft.ClearScript.V8.ICUData.props')" />
Now the initial issue was fixed but during executing script I see the following error:
Cannot load ClearScript V8 library. Load failure information for ClearScriptV8.win-x64.dll:
C:\Users\User\AppData\Local\Temp\Temporary ASP.NET Files\vs\...\runtimes\win-x64\native\ClearScriptV8.win-x64.dll: The specified module could not be found
C:\Users\User\AppData\Local\Temp\Temporary ASP.NET Files\vs\...\ClearScriptV8.win-x64.dll: The specified module could not be found
D:\pathtoproject\ClearScriptV8.win-x64.dll: The specified module could not be found
D:\pathtoproject\bin\ClearScriptV8.win-x64.dll: The specified module could not be found
C:\WINDOWS\system32\ClearScriptV8.win-x64.dll: The specified module could not be found'
What am I doing wrong? And how can I resolve this issue?
What's assembly manifest from initial issue? Maybe some .xml file was missed into package folder or something else? (because I see in bin folder for example ClearScript.V8.dll and ClearScript.V8.xml files)

Try excluding ClearScript's native assemblies from compilation by merging the following into all of your Web.config files:
<system.web>
<compilation>
<assemblies>
<remove assembly="ClearScriptV8.win-x64" />
<remove assembly="ClearScriptV8.win-x86" />
</assemblies>
</compilation>
</system.web>

Related

nuget local feed stops working when package with two different versions is present

I am trying to use nuget local feed for publishing my packages. So, I tried to push my first component / package. I have the following nuget.config in my sdk project:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
<add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" />
<add key="local feed" value="x:\nuget\packages\" />
</packageSources>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<bindingRedirects>
<add key="skip" value="False" />
</bindingRedirects>
<packageManagement>
<add key="format" value="0" />
<add key="disabled" value="False" />
</packageManagement>
</configuration>
SDK Project's configuration is as follows:
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Title>My custom component</Title>
<Version>0.0.1-alpha</Version>
<PackageId>$(RootNamespace)</PackageId>
</PropertyGroup>
I set the project to Release configuration, and execute Pack command. As a result, .nupkg file is created in bin/Release folder.
Inside the package manager console window, I execute the following command:
nuget add pathToNupkgFile -Source x:\nuget\packages
So far so good, package is located in folder x:\nuget\packages\companyname.components.blazor.mycomponent\0.0.1-alpha.
Now I created new solution where I want to consume package from local feed. I copied the same nuget.config file to folder where new solution was created. I open Manage Nuget Packages for Solution (short MNPfS), search for new package, and install it. All fine until this point.
Now, if I do the same procedure and create 0.0.2-alpha nupkg, after nuget add command, new version is present in x:\nuget...., but I am unable to browse local feed any more in MNPfS screen. As soon as I open MNPfS, I get following message in window where packages should be listed:
Error occured
And error list window displays following message:
Error [local feed] '.', hexadecimal value 0x00, is an invalid character. Line 1, position 1.
Now, if I delete version 0.0.1-alpha from local feed repository, then I can browse again in MNPfS and new package is displayed, and can be installed. So, the problem occurs only when two versions of same package are present.
Anyone knows why is this happening, and how can I have multiple versions of same package in local feed?
Looks like the problem was related to nuget add command -Source parameter. When source points to partition with FUSE file system, then it does not create proper nuspec file, although no error is provided in Package Manager console.
nuspec file results in content with multiple NULL values. If I specify -Source to current partition where project is, then nuspec file is properly created, and then I can just copy the content to FUSE file system, and all works OK.

How to get the myget package source?

I am using myget for my Nuget packages. Because i am using a private feed with credentials, i followed this blog: http://www.xavierdecoster.com/deploying-to-azure-web-sites-using-nuget-package-restore-from-a-secured-feed
My local (project) nuget.config (located in the .nuget folder in the solution) looks like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
<packageSource>
<clear />
<add key="EcareMyGet" value="https://www.myget.org/F/rai69/"></add>
</packageSource>
<activePackageSource>
<add key="EcareMyGet" value="https://www.myget.org/F/rai69/"></add>
</activePackageSource>
<packageSourceCredentials>
<EcareMyGet>
<add key="Username" value="www.myget.org/raimond" />
<add key="ClearTextPassword" value="wachtwoord" />
</EcareMyGet>
</packageSourceCredentials>
</configuration>
In my nuget.targets i've changed the restore command according to the blog:
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -NonInteractive $(RequireConsentSwitch) -solutionDir "$(SolutionDir)\" -Verbosity detailed </RestoreCommand>
Despite this, the buildserver is still using nuget.org as source:
NuGet.exe sources
Registered Sources:
1. https://nuget.org/api/v2/ [Enabled]
https://nuget.org/api/v2/
Who knows a solution?
Answer: replace <packageSource> by <packageSources> in the nuget.config file
Below is the conversation that lead to the answer...
Just to be sure, did you also read the part where you disable the -RequireConsent switch?
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">
false
</RequireRestoreConsent>
Also, make sure you didn't configure it in the MSBuild PackageSources element, which by default looks as shown below (no package source configured):
<ItemGroup Condition=" '$(PackageSources)' == '' ">
<!-- Package sources used to restore packages.
By default, registered sources under %APPDATA%\NuGet\NuGet.Config
will be used -->
<!-- The official NuGet package source (https://nuget.org/api/v2/) will be
excluded if package sources are specified and it does not appear
in the list -->
<!--
<PackageSource Include="https://nuget.org/api/v2/" />
<PackageSource Include="https://my-nuget-source/nuget/" />
-->
</ItemGroup>
If you did and that's not the issue, can you please share a little more detail about the output logs so I can determine when the issue is caused and by what command?
You write that you use "My local (project) nuget.config", which makes me believe that you have the nuget.config file located in your project folder.
You can read about the NuGet Config File here. There you'll see that "NuGet first loads NuGet.config from the default location, then loads any file named NuGet.config starting from the root of the current drive and ending in the current directory.".
What this means, it that NuGet will look for the configuration in the folder hierarchy all the way from the root and to the location of nuget.exe, which usually is under the .nuget folder in the solution root. This means that it will never look inside the project folders in your solution. So you can try to move your nuget.config to the solution folder, and see it it gets read properly then.

Deploying MVC4: System.IO.FileNotFoundException [duplicate]

I have a small web application. Which was working fine until I added two genericHandler in my application.
I have made the following changes for the http handler
<system.web>
<authentication mode="Forms" >
<forms protection="All" timeout="720" defaultUrl="Default.aspx" loginUrl="Login.aspx" >
</forms>
</authentication>
<authorization>
<deny users="?"/>
</authorization>
<compilation debug="true" targetFramework="4.0" />
<httpHandlers>
<!--Code Log Handler-->
<add verb="*" path="*.aspx" type="System.Web.UI.PageHandlerFactory" />
<add verb="*" type="InfoDomeNewUI.Handler.SendOWA" path="SendOWA.ashx" />
<add verb="*" type="InfoDomeNewUI.Handler.SendSOS" path="SendSOS.ashx" />
</httpHandlers>
<customErrors mode="Off">
<error statusCode="404" redirect="Templates/PageNotFound.html" />
</customErrors>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<!--Code Log Handler-->
<add name="LogHandler1" path="SendOWA.ashx" verb="*" type="InfoDomeNewUI.Handler.SendOWA"/>
<!-- SMS SENDER-->
<add name="SendSOS" path="SendSOS.ashx" verb="*" type="InfoDomeNewUI.Handler.SendSOS"/>
</handlers>
</system.webServer>
Could not load file or assembly 'Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
I am using asp.net4.0 and C#. I am not using MVC
On local host it is working fine.
But when I am hosting the published code it is giving me the above error.
Stack Trace:-
[FileNotFoundException: Could not load file or assembly 'Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
System.Web.Http.WebHost.SuppressFormsAuthRedirectModule.Register() +0
[InvalidOperationException: The pre-application start initialization method Start on type System.Web.Http.WebHost.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified..]
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +11708830
System.Web.Compilation.BuildManager.CallPreStartInitMethods() +465
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLeve
[HttpException (0x80004005): The pre-application start initialization method Start on type System.Web.Http.WebHost.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified..]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11697760
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4866485
It appears that Microsoft.Web.Infrastructure.dll is not being installed in the GAC, even if .net (4.0 or 4.5 or other) are installed successfully on Windows Server. On localhost (typically Windows client), it seems like it is being in the GAC when the tools/platform (Visual Studio etc.) are installed.
As one possible fix, please try the following:
Run the following command in the Package Manager Console. (If you are using Visual Studio, this can be reached via menu options "Tools --> Library Package Manager --> Package Manager Console:)
PM> Install-Package Microsoft.Web.Infrastructure
You will see the following messages if it is successfully installed.
Successfully installed 'Microsoft.Web.Infrastructure 1.0.0.0'.
Successfully added 'Microsoft.Web.Infrastructure 1.0.0.0' to Web.
You will notice that Microsoft.Web.Infrastructure.dll has now been added as a Reference (can be seen in the references folder of your project in in Solution Explorer)
If you look at the properties of this reference you will notice that "Copy Local" has been set to "True" by default.
Now when you "Publish " your project, Microsoft.Web.Infrastructure.dll will be deployed.
I installed MVC4 via WPI and it helped me.
I had the same problem. When I tried the accepted answer (rockyb), I got the message that the package was already installed and assigned to my project. When I checked the references list, it was NOT referenced, however.
The Microsoft.Web.Infrastructure was installed in my solution's packages folder. Instead of using NuGet to add the package, I just used the Add Reference option. On the left side of the pop-up window, I chose Browse, and then pressed the Browse button on the bottom of the window. I navigated to the packages folder under the folder that my solution was in, then drilled down to the ...\mysolution\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40 and clicked on the Microsoft.Web.Infrastructure.dll. After clicking OK, the package showed up in my References list. I used the Web Deploy Package option to deploy my website and everything worked.
Why not copy Microsoft.Web.Infrastructure.dll file manually to the server BIN folder. This works for. My project is VS2010 Website.
This file can be located:
C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40
Just copy and paste it in the BIN folder.
You probably need to include this in the web.config if you don't have it already
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
Reference: http://thedeveloperblog.com/
I found the problem. Instead of adding a class (.cs) file by mistake I had added a Web API Controller class which added a configuration file in my solution. And that configuration file was looking for the mentioned DLL (Microsoft.Web.Infrastructure 1.0.0.0).
It worked when I removed that file, cleaned the application and then published.
After installing Microsoft.Web.Infrastructure through Nuget-Package Manager
PM> Install-Package Microsoft.Web.Infrastructure
Copy the Microsoft.Web.Infrastructure.dll manually from the Nuget-Package folder on your web application and then paste it in your bin folder of your web application deployed on the web server.
packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll
It worked for me.
Update-Package -reinstall Microsoft.Web.Infrastructure didn't work for me, as I kept receiving errors that it was already installed.
I had to navigate to the Microsoft.Web.Infrastructure.1.0.0.0 folder in the packages folder and manually delete that folder.
After doing this, running Install-Package Microsoft.Web.Infrastructure installed it.
Note: CopyLocal was automatically set to true.
Sometimes needs to delete the package with force then reinstall it
its works for me.
try delete package
Uninstall-Package Microsoft.Web.Infrastructure -force
then install again
Install-Package Microsoft.Web.Infrastructure
I had the same problem and the "Microsoft.Web.Infrastructure.dll" appeared to be missing. I have tried few advises and installed MVC`s etc. and nothing helped. The solution was to install "Web Services Enhancements (WSE) 1.0 SP1 for Microsoft .NET" which includes Microsoft.Web.Infrastructure.dll.
Available at: http://www.microsoft.com/en-gb/download/details.aspx?id=4065
I had the same problem. I tried installing Visual Studio 2010 SP1 but it didn't worked.
Finally I get Microsoft.Web.Infrastructure.dll from the colleague. You can find the dll into your friends PC where the project is perfectly working. Try to search dll into Temp/Temporary ASP.NET Files. Go to Temp using %temp% into run window.
After getting dll into your pc, just add reference to your project and it will work.
Republishing the site fixed the issue for me.
Was facing the same issue and unfortunately nothing here was working. Finally, I came across this link: https://blogs.msdn.microsoft.com/jjameson/2009/11/18/the-copy-local-bug-in-visual-studio/
Turns out the solution is sort of dumb: set copy-local for the microsoft.web.infrastructure dll to False, then set it back to True.
By the way, I think what is happening is that there are two versions of the microsoft.web.infrastructure dll, one that is pre-installed in the GAC, and another one that is now a nuget package. I think one is masking the other, hence causing issues. In my particular case, on my build server, I need it to be copied over to a folder (this folder is then zipped and sent off to deployment). I guess the system had a copy locally and just thought "nah, it'll be fine"
I have a files only website. Added MVC 5 to webforms application (targeting net45). I had to modify the packages.config
package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net45"
to
package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net45" developmentDependency="true"
in order for it to startup on local box in debug mode (previously had the top described error). Running VS 2017 on Windows 7...opened through File > Open > Web Site > File (chose root directory outside of IIS).
I had the same problem after upgrading a bunch of NuGet packages.
I have tried all kinds of deleting, cleaning, resintalling described here and beyong to no avail. The references did not have Microsoft.Web.Infrastructure despite the NuGet manager showed it was installed.
The problem was solved by replacing:
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
with
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net46" />
in packages.config. The culprit is apparently "net45".
Visual Studio 2022 .net.4.8
I just run this and is solved
you can install this dll using nuget package manager
PM> Install-Package Microsoft.Web.Infrastructure -Version 1.0.0

Moles creation does not create all objects

While trying to create a mole for some unit tests I noticed that some functions were not being 'moled'. Some functions were appearing in the xxx.moles.xml file while others were not.
To resolve this issue, I've tried reinstalling 'Pex and Moles', deleted files in the MolesAssembly folder, restarted the computer, etc.
Finally, I simply opened a console window and ran the moles.exe command from the command prompt.
"c:\program files\microsoft moles\bin\moles.exe" assembly.dll /op:"MolesAssemblies" /msbuild:"c:\windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe"
The first time I ran this, I received a message:
Moles : info : compilation : assembly metadata hash unchanged,
skipping code generation.
After deleting the moles in the MolesAssemblies folder, I ran the moles.exe command again and all my functions are now appearing in the xxx.moles.dll and xxx.moles.xml files.
Does anyone know why the mole generation does not work when building inside Visual Studio 2010, but it works perfectly from the command prompt?
I found the issue...I modified the .moles file before and only certain classes were added. I simply had to add more 'TypeName' and the classes/functions were included.
The reason that it 'worked' by using the moles.exe command was because I did not use the .moles file (I simply referenced the assembly). I changed the parameters for moles.exe to include the .moles file and the assembly and the results were identical to the output generated by Visual Studio. Once I notice that other parts of the code was breaking, I realized that the .moles file was incorrect.
I had something like this...
<Moles xmlns="http://schemas.microsoft.com/moles/2010/" >
<Assembly Name="Assembly.name" />
<StubGeneration>
<Types>
<Clear />
<Add FullName="Fullname_1_0" />
</Types>
</StubGeneration>
<MoleGeneration>
<Types>
<Clear />
<Add FullName ="Fullname_1_0" />
</Types>
</MoleGeneration>
</Moles>
I needed a second 'Add'
<Moles xmlns="http://schemas.microsoft.com/moles/2010/" >
<Assembly Name="Assembly.name" />
<StubGeneration>
<Types>
<Clear />
<Add FullName="Fullname_1_0" />
</Types>
</StubGeneration>
<MoleGeneration>
<Types>
<Clear />
<Add FullName ="Fullname_1_0" />
<Add TypeName="AdditionalClass"/>
</Types>
</MoleGeneration>
</Moles>
Be sure to REBUILD the test project, after modifying an assembly that is moled. Using the "clean" action on the test project will also fix this issue.

'compilerVersion' attribute in the provider options must be 'v4.0' or later

Getting this error:
The value for the 'compilerVersion'
attribute in the provider options must
be 'v4.0' or later if you are
compiling for version 4.0 or later of
the .NET Framework. To compile this
Web application for version 3.5 or
earlier of the .NET Framework, remove
the 'targetFramework' attribute from
the element of the
Web.config file.
It was working on our dev system, and we are now deploying to QA using an xcopy type deploy.
We don't have a "compilerVersion" anywhere in the web.config, and the targetFramework is set to "4.0". We have done an IISReset.
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
UPDATE 2: when we removed the entire section, we got past the error. So my question is, what is wrong with leaving in this section if we are on .NET 4.0?
We just did a full xcopy of exactly what was in Test to QA, and in QA it gets the error and DEV doesn't. So the software and configs are identical. Why would it work on one server and not another? IIS options seem to be identical.
taken from: http://www.asp.net/whitepapers/aspnet4/breaking-changes#0.1__Toc256770150
you should go to your server root web.config and include the whole
<system.codedom>...</system.codedom>
tag content into a
<location path="" inheritInChildApplications="false">...</location>
tag
Possible solution here - asp.net/whitepapers/aspnet4/breaking-changes#0.1__Toc256770150
After fighting with this for a while, I ended up creating a new IIS site using a different port and adding my ASP.Net 3.5 application to the new site and it is working perfectly.
I got the same error and found out that my v4.0 website was hosted under the default website that was v2.0. If you've such setup then you need to remove the following line from your web.config:
<compilation defaultLanguage="c#" debug="true" targetFramework="4.0"/>
I hope that helps.