How to register Assembly .net 4.0 in windows 7 GAC? - assemblies

Hi i'm using vs2010 to create a .net 4.0 assembly that i pretend to register on the GAC.
i can't find the gacutil and don't know ho to register an assembly on the 4.0 GAC
can someone help?
SOLUTION FOUND:
Register using GacUtil located in: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools

You can either copy your assembly to your:
%windir%\assembly
folder, or use the Global Assembly Cache Utility found in the Microsoft SDK or Visual Studio SDK.

Related

Why is my ASP.NET Web Site project targeting .NET Framework 4.6.1 when I have told it to target 4.8?

We have a large Visual Studio 2015 solution with several Web Site (as opposed to Web Application) projects and dozens of business-logic DLL projects. We were targeting .NET Framework 4.6.1, but I've now installed Visual Studio 2019 on my local PC and re-targeted all the projects to 4.8
When I build the solution using our existing PowerShell/MSBuild script, all the DLLs build successfully, but I get the following error when it comes to our first Web Site project:
C:\[omitted]_MyWebSite.metaproj : warning MSB3274: The primary reference
"C:\[omitted]\MyDLL.dll" could not be resolved
because it was built against the ".NETFramework,Version=v4.8"
framework. This is a higher version than the currently targeted
framework ".NETFramework,Version=v4.6.1".
Then later, when the compiler reaches some code on the site that tries to use the DLL:
c:\[omitted]MyController.cs(6): error CS0246: The type or namespace
name 'MyDLL' could not be found (are you missing a using directive or
an assembly reference?) [C:\[omitted]_MyWebSite.metaproj]
(This is just a sample reference error. In fact, all of the DLLs seem to suffer from this issue wherever they are used in the Web Site project.)
Relevant lines in the site's web.config file:
<location path="." inheritInChildApplications="false">
<system.web>
[omitted]
<httpRuntime targetFramework="4.8" requestValidationMode="2.0" maxRequestLength="10240" />
<compilation debug="true" strict="false" explicit="true" targetFramework="4.8">
I am using the following MSBuild.exe path:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\msbuild.exe -maxcpucount:1 -verbosity:detailed
Looks like it's not enough to update the web.config file for Web Site Projects. You also have to update the target in the property pages. So in Solution Explorer, find your Web Site Project, right-click > Property Pages > Build > Target Framework > change to .NET Framework 4.8.
This is independent of the web.config file and resulted in a change in my .sln file from:
ProjectSection(WebsiteProperties) = preProject
[...omitted...]
TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.6.1"
to:
ProjectSection(WebsiteProperties) = preProject
[...omitted...]
TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.8"

Building Core2.0 project in Visual Studio Team Services fails with numerous assembly import errors

I have Build Definition
.NET Core Restore
.Net Core Build
.Net Core Test
.Net Core Publish
Publish Artefact
While I was using Core1.1 it worked without any issue. But after upgrading project to Core2.0 it fails with multiple errors like
error CS1703: Multiple assemblies with equivalent identity have been imported: 'C:\Users\buildguest\.nuget\packages\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.Threading.Tasks.Parallel.dll' and 'C:\Users\buildguest\.nuget\packages\system.threading.tasks.parallel\4.3.0\ref\netstandard1.1\System.Threading.Tasks.Parallel.dll'
error CS0433: The type 'TargetFrameworkAttribute' exists in both 'System.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
error CS0518: Predefined type 'System.String' is not defined or imported
Solution is perfectly building locally. I tried to add task Use .NET Core runtime 2.0.0 in the beginning but without any success.
You should add .NET Core Tool Installer task at the beginning of the build steps. Then install the SDK not only runtime. Then save your build definition and queue again.

Dependency on the framework assembly "System.Runtime, Version=4.0.10.0," which could not be resolved in the currently targeted framework

TFS 2013 - Build: ASP.Net 4.5.1 website I get this error:
warning MSB3268: The primary reference "C:\Builds\2\MyProj\Web1_Main\bin\MyProj1.dll"
could not be resolved because it has an indirect dependency on the framework assembly
"System.Runtime, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which
could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.5.1". To resolve this problem, either remove the reference
"C:\Builds\2\MyProj\Web1_Main\bin\MyProj1.dll" or retarget your application to a framework
version which contains "System.Runtime, Version=4.0.10.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a".
All projects and site was 4.0 initially using Unity 1.0.0.0. I upgraded it to 4.5.2. Also the MyProj1 in the error above is referencing Unity and I upgraded it to 3.5.1 as well.
Read this: https://unity.codeplex.com/workitem/12756
The build server already have the updated 4.5.2 pointed in the workaround.
So I downgraded to 4.5.1 but still getting the error.
Solution builds fine locally via Visual studio 2013.
The stand alone class libraries project build in TFS fine but when MyProj is added as a reference to my Website, that's when it fails.
Any ideas?
Do I need any web.config changes other than TragetFramework settign while upgrading?
I had to upgrade my Unity to 3.5 due to my project's dependency on some other project and this error came again. This time, finally got it fixed.
This one helped me: http://devsilos.blogspot.com/2014/10/msb3268-while-targeting-aspnet-web-site.html
Solution I copied all the files that build was complaining about from:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\Facades
To
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2
Here's the explanation from the link above in case it goes down for any reason in future:
A deeper inspection revealed the following interesting fact:
aspnet_compiler for some reason does not take into account the .dll-s
that reside under the Facade directory of 4.5 assemblies (C:\Program
Files (x86)\Reference
Assemblies\Microsoft\Framework.NETFramework\v4.5\Facades). It looks
only under C:\Program Files (x86)\Reference
Assemblies\Microsoft\Framework.NETFramework\v4.5
As a result the whole thing failed since both System.Threading.Tasks
and System.Runtime .dll-s were under the Facades directory and not
inside the v4.5.
Now the solutions:
Just simply copy the missing .dll-s from Facade to the v4.5
directory.
Set the TargetFrameworkMoniker to 4.5.1 in the .sln file. The exact
syntax is as follows: TargetFrameworkMoniker =
".NETFramework,Version%3Dv4.5.1".
What happens in this case is that the aspnet_compiler does not
recognize the exact version of the required framework and tries to
use the GAC wherever it can. If 4.5 is the highest version installed
on the build machine I believe it should work.
Actually sorry I don't think "assemblyBinding" would help.
It seems like a known bug. It has not been resolved. Using Unity 3.5 you can target .NET 4.5.1 but not 4.5.2.
So one option would be to re-target to .NET 4.5.1 and see if the problem goes away, if that's an option.
p.s.
Also you can try .NET Framework 4.5.2 Developer Pack. But some have mentioned it did not work.
We recently ran into a similar problem with a site that was upgraded to target .NET 4.5, and initially followed the solution in gbs's answer.
In our case, we had several warnings following this pattern:
<project name>.metaproj : warning MSB3268: The primary reference "<project reference>.dll" could not be resolved because it has an indirect dependency on the framework assembly "System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.5". To resolve this problem, either remove the reference "<project reference>.dll" or retarget your application to a framework version which contains "System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
We then discovered that if you create a new web site targeting 4.5.x (File > New > Web Site...) and select the ASP.NET Empty Web Site template, the package Microsoft.Net.Compilers is included. Adding this package to our site resolved the issue without the need to touch the reference assemblies.
Of the original two solutions, copying the files caused the build to succeed but presented maintenance concerns, and changing the TargetFrameworkMoniker (to 4.5.3 rather than 4.5.1) produced a different build error and was a brittle solution.

ASP .NET Web Forms: Could not load file or assembly 'System.Web.WebPages.Deployment, Version=2.0.0.0

I moved my existing ASP .NET web sites and web applications to a new server, and I'm getting the following error:
Could not load file or assembly 'System.Web.WebPages.Deployment,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or
one of its dependencies. The system cannot find the file specified.
I located this assembly on my computer, and copied it to the BIN folder of my web site. It gives a new error:
Could not load file or assembly 'System.Web.WebPages.Deployment,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or
one of its dependencies. The located assembly's manifest definition
does not match the assembly reference. (Exception from HRESULT:
0x80131040)
Does this mean ASP .NET is not properly installed on the server machine? How do I go about fixing this? I also noticed that the assembly is present on my computer somewhere in the Program Files (x86)/Microsoft ASP.NET folder. However, the Program Files (x86)/Microsoft ASP.NET folder does not exist on the server.
Solution: I installed both ASP .NET Web Pages and ASP.NET MVC 4 on the server. This installed the missing assemblies and created the folders that were missing.
The exceptions speak for themselves: Your project has referenced version 2.0.0.0 of this assembly and you have copied version 1.0.0.0
Find the correct version and you'll be OK

Oracle.ManagedDataAccess The system cannot find the file specified

In my website project built on .net 3.5, when I add reference to the Oracle.ManagedDataAccess.dll by adding this in the web.config
<add assembly="Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89B483F429C47342"/>
it give this error
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Could not load file or assembly 'Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. The system cannot find the file specified.
This error comes at .net version 3.5
The solution is to upgrade the .net version to .net 4.0 or above
Upgraded my project version to .NET 4.8 from .NET 4.5.2 and then
Installed the OracleManagedDataAccess nuget package into the solution (seems it wasn't installed)
This resolved the error.

Resources