I had an asp.net website project with some missing DLL files. I found the DLLs and added them back into the "Lib" folder which sits one level above may main project, however within my aspx code if I type "using CMS.Base" I get a not found.
I looked in the .proj file and I can see:
<Reference Include="CMS.Base, Version=8.0.0.0, Culture=neutral, PublicKeyToken=834b12a258f213f9">
<HintPath>..\Lib\CMS.Base.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
Is there something else I should be looking at?
C
Related
Im having an issue when upgrading Telerik references in a VS2019 C# project. Current version is 9.0.* and upgrade version is 16.1.*.
In the .csproj with the current version the reference is defined this way
**<Reference Include="Telerik.Reporting">
<HintPath>..\dll\External\Telerik.Reporting.dll</HintPath>
<SpecificVersion>False</SpecificVersion>**
If i update the reference from add reference->assemblies->extensions the .csproj code looks like this, and its ok:
**<Reference Include="Telerik.Reporting, Version=16.1.22.622, Culture=neutral, PublicKeyToken=a9d7983dfcc261be, processorArchitecture=MSIL" />**
But here comes the issue. I have to do a local copy inside my project of the telerik.reporting.dll. So I pick the C:\Program Files (x86)\Progress\Telerik Reporting R2 2022\Bin\Telerik.Reporting.dll and copy it inside my C:\GIT\MySolution\dll\external folder.
Once i have the file copied i update the reference from add reference->browse. And then the .csproj looks like this
**<Reference Include="Telerik.Reporting, Version=9.0.15.225, Culture=neutral, PublicKeyToken=a9d7983dfcc261be, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\dll\External\Telerik.Reporting.dll</HintPath>
</Reference>**
The version of the telerik.reporting.dll in my external folder is 16.1.* but somehow the .csproj code now shows the 9.0.* and dont now why.
Thanks for your help.
I'm not sure why am I getting this error now. I referenced an assembly out of Nuget package that is in turn referenced in packages.config file.
This is how the assembly is referenced in my csproj file:
<Reference Include="System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll</HintPath>
</Reference>
I tried to delete the reference in VS and re-reference it again from packages folder without any luck.
Following article mentiones GAC and appbase, but I'm not sure how to find those paths any why the compiler would even look there if the correct file is referenced in my csproj?
The located assembly’s manifest definition with name xxx.dll does not match the assembly reference
One more place to check was Web.config. As soon as version conflict was fixed there everything worked.
3 places to check for reference conflicts are:
*.csproj
packages.config
Web.config
I have an assembly that is registered in GAC. In 'Windows/assembly' folder I can see it and also see its PublicKeyToken 'aaaa'. I have a SSIS solution (I think no matter at all what is the type of solution).
SSIS package has many c# scripts, each of them has its own references. Some of them contains reference for my assembly. I see the same path to the assembly in properties for it in each script. BUT one of the scripts has another PublicKeyToken 'bbbb' (the others have 'aaaa'). And it breaks the whole solution. Build works good, but Run fails. How can I manage such situation?
Update: issue appeared after new version of assembly has been added to the GAC. the old one has been deleted.
I tryed to change reference for a copy of dll but the problem doesn't go away. Maybe is there any way to set PublicKeyToken? I've even tryed to change compiled file (but what if? =))
In .dtsx file (file for compiled package) it looks like:
for one script:
<Reference Include="MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=bbbb, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\assembly.dll</HintPath>
</Reference>
for the others:
<Reference Include="MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=aaaa, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\assembly.dll</HintPath>
</Reference>
I'm converting my project from MVC 4 to MVC 5 (and .Net 4 to .Net 4.5.2, which is the real driver of the changes.)
When I run one of my pages I get this error (blank space added by me for easier reading)
[A]System.Web.WebPages.Razor.Configuration.HostSection cannot be cast
to [B]System.Web.WebPages.Razor.Configuration.HostSection.
Type A originates from 'System.Web.WebPages.Razor, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context
'Default' at location
'C:\windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Razor\v4.0_1.0.0.0__31bf3856ad364e35\System.Web.WebPages.Razor.dll'.
Type B originates from 'System.Web.WebPages.Razor, Version=3.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context
'Default' at location
'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET
Files\studentportal3g\2204bad2\aece9b3b\assembly\dl3\ad80387c\91adbf51_fc73d101\System.Web.WebPages.Razor.dll'.
When I first saw this is though, Ah easy! Not so much :)
I've gone over every project and made sure it's version is upgraded to MVC 5 which has the 3.0.0.0 version of System.Web.WebPages.Razor.dll.
Clean rebuild, still get the error. No problem , I'll delete the cached temp files.
Clean rebuild, still get the problem. I go back, manually check each version of System.Web.WebPages.Razor.dll, in the references of each project that has a reference to it. I check my folder where I copy dlls to make references to them manually, it's not there.
If my solution doesn't' contain a copy of the DLL or a reference to the DLL, and I've manually deleted the cache folders in 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET
Files\studentportal3g...
Where is the old bad dll coming from? How do I fix this error? How do I prevent it happening again?
Thanks,
Eric-
Visual Studio is a great tool, but it doesn't always make the right choices when it comes to upgrading dependencies, nor does it support every possible option available in MSBuild. Whenever you find yourself in a bind such as this you should manually review and (if necessary) edit your .csproj file in order to resolve it.
The problem isn't that your file exists in the GAC or that it has not been installed by NuGet, the issue is most likely that one of your project files still has a reference to the old version of System.Web.WebPages.Razor version 1.0.0.0, and you need to find all references to it and change them to 3.0.0.0 accordingly.
Right-click on your project node in Solution Explorer and click Unload Project.
Right-click the project node again and click Edit <projectName>.csproj.
Search the file for references to System.Web.WebPages.Razor and update the version and the HintPath accordingly (as shown below). Make sure the HintPath you use actually points to an existing file.
Repeat these steps for all dependent projects in the solution (and any that are in DLLs that are not part of the solution).
Old Reference
<Reference Include="System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.AspNet.WebPages.1.0.20105.408\lib\net40\System.Web.WebPages.Razor.dll</HintPath>
</Reference>
Updated Reference
<Reference Include="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.0.0\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
</Reference>
You should also go through the web.config and /Views/web.config files to ensure that they are not referencing any old versions of this assembly.
NOTE: If the above instructions don't solve your issue, the issue likely is outside of your solution. Most likely there is a 3rd party library that is referencing the old version of the file somewhere. If so, you could attempt to get an updated version of the DLL.
You may also want to check out this question.
It looks like the old DLL is in the Global Assembly Cache (GAC). The GAC is a place where you can store assemblies that can be referenced from several applications on the machine. Click here to read more about GAC.
Use the tool gacutil to update the assembly in the GAC.
The tool is located somewhere under "Microsoft SDKs" folder in Program Files. For me, it was located in
C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\
Open cmd and navigate to the place where gacutil i stored. Then use it like this:
gacutil.exe -i [path to your assebly] -f.
The -i parameter is for indicating where your assembly is located. The -f parameter is used to force an update of the assembly, if it was already there.
Example
Say your DLL is located in
C:\temp\System.Web.WebPages.Razor.dll
Then you would run gacutil.exe -i "C:\temp\System.Web.WebPages.Razor.dll" -f
I have various projects which reference assemblies within C:\Program Files (x86). I have installed the assemblies on my build controller in the exact same way and the files are in the C:\, however whenever I trigger a build my controller doesn't find the assemblies.
<Reference Include="GrapeCity.ActiveReports.Diagnostics.v7, Version=7.0.6163.0, Culture=neutral, PublicKeyToken=..., processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
</Reference>
The reference in the project looks like the above, which in my opinion I can understand why the build controller can't find the reference because there are no hint paths.
I have tried changing Copy Local to true and Specific Version to false, this also didn't work. What should I change in my project, build controller or build definition to make the server have scope of the assemblies?
So one way to solve this is to not reference from the GAC.
<Reference Include="GrapeCity.ActiveReports.Diagnostics.v7, Version=7.0.6163.0, Culture=neutral, PublicKeyToken=..., processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
</Reference>
Find this GrapeCity.ActiveReports.Diagnostics.v7.dll.
Where your .sln file resides, create a .\ThirdPartyReferences\ folder.
Copy GrapeCity.ActiveReports.Diagnostics.v7.dll to that directory.
Remove the "gac" reference.
Add the more local .\ThirdPartyReferences\ reference.
Check .\ThirdPartyReferences\ folder into source control.
Make sure .\ThirdPartyReferences\ is "pull down" from source control during the build.
OR
Get "GrapeCity.ActiveReports" installed on the build-server using their install tools.
Which should get into correctly into the GAC on the build server.
I usually choose the first option (my first option above).
I like having a very good handle on what my ThirdParty dependcies are for my build.