Fully qualified name for .NET 4.0 assembly - .net-4.0

I am having some problems getting my httpHandler working with an assembly deployed in the GAC.
My assembly is created in the .NET 4.0 Framework. Because of the .NET 4.0 framework my dll is not deployed to the C:\Windows\assembly but it is deployed to C:\Windows\Microsoft.NET\assembly\GAC_MSIL folder.
I tried to put the fully qualified name in my web.config but still when I try to open my webpage I get the error "assembly-name or codebase not valid"
Hopefully someone can give me tips to get my assembly in the C:\Windows\assembly or how I can make use of the dll that is deployed in the GAC_MSIL folder.
Thanks.

Related

Self-contained Asp.net core (1.0.1) app cannot find RestSharp dll

I have an ASP.Net Core (1.0.1) web app. One of the packages it consumes itself consumes RestSharp. When built, the RestSharp dll is indeed in the app root. But when I deploy and browse to the app, I get the following error:
Application startup exception: System.IO.FileLoadException: Could not load file or assembly 'RestSharp, Version=105.2.3.0, Culture=neutral, PublicKeyToken=8d483824b1b4e30c' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'RestSharp, Version=105.2.3.0, Culture=neutral, PublicKeyToken=8d483824b1b4e30c'.
Let me be clear, here... the dll is the correct version: 105.2.3.0.
Now, if I register RestSharp to the GAC, all is well and the website works. But this is a .Net Core self-contained app and it shouldn't be looking in the GAC at all (should it??).
I'm really lost and confused. I honestly don't know what's going on, so I really could do with some help.
App folder after publishing:
MyApp/
MyApp.exe
....
....
etc.
RestSharp.dll (v105.2.3.0)
web.config
appsettings.json
UPDATE:
Sorry, I should have also mentioned that I'm targetting net46.
As mason rightly pointed out: You said "This is a .NET Core self contained app". But that's not true if you're targeting .NET Framework 4.6.

ASP.NET vnext bin dll

Normally, we put the dll in the bin folder and thats it
Now I put the interop dll within SQLite.Interop.dll on wwwroot/bin/
but still get this error
An unhandled exception of type 'System.DllNotFoundException' occurred in mscorlib.dll
where should I put the interop dll on asp.net vnext?
I don't have a correct answer for you, but I do have one that works: put the dll in the Windows System32 directory.
C:\Users\{change into your window username}\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta7\bin
Works in asp.net vnext beta 7
Update 25-09-2015
After testing with another machine, that path is not always correct.
To be sure, check "path" environment variables.
On my case, the dnx runtime pointing to C:\Users\{change into your window username}\.dnx\bin
I put my sqlite3.dll over there and I can use sqlite on .net core :)

Issues while upgrading System.Web.Extensions dll reference from 3.5 to 4.0

I need to migrate a website built on .net framework 3.5 to 4.0 and it should work fine in IE9
The solution got upgraded by the VS's version utility and the app compiled successfully. We are using Infragistics UltraWebGrid control v11.1 which is giving some script issue when we try to perform scroll or cell edit. The control has got lot of embedded javascript resource files which seems to be not working fine.
I created a poc website of .net framework 4.0 using the same third party dlls and everything works fine. What I can doubt on is the AJAX part. I tried to consume v4.0 of ajaxcontroltoolkit. But the issue what I am facing is, the toolkit internally references System.Web.Extensions.dll of version 4.0 and my application has many references to the dll of v3.5. Adding the reference to v4.0 doesn't replaces the references to v3.5 in the web.config. Finally I manually updated the version info in web.config which has given birth to other errors.
-Unknown server tag 'asp:ScriptManager','asp:UpdatePanel' etc..
-The type or namespace name 'Script' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
Please give me some suggestions to upgrade the dll references successfully.
Thanks,
Vaishali

Compile .net 4.0 project on build server with .net 4.5

We're having the seemingly common error
Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
in a project that needs to be compiled against .Net 4.0 but is built on a build server running Windows Server 2012 (with .Net 4.5). The project is a web application that gets deployed to a web server running 2003, where installing .Net 4.5 isn't an option. There it runs against "classic" .Net 4.0
From similar questions, we're trying command-line options to MSBuild:
/property:FrameworkPathOverride="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0"
We also tried various combinations of
/property:ReferencePath="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0"
/property:NoStdLib=true
/property:NoCompilerStandardLib=true
The reference assemblies (including the .dll files) are in fact installed in that place on the build server. But when we deploy the website and visit the home page, we get that error. (Interestingly, on a page reload, the error disappears, and the site operates normally.) What are the MSBuild parameters necessary to compile against the .Net 4.0 assemblies?
Update
I turned on ludicrous-level logging on MSBuild, and I see that apparently it is building against the .Net 4.0 reference assemblies:
Resolved file path is "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\mscorlib.dll
and I didn't see any mention of assemblies outside that folder or the build server's working directory. So it appears to compile properly, but when deployed on the web server, it throws the exception.
As to the exception going away on a page reload, I wonder if that's related to the markup pre-compile step. We're running aspnet_compile on the build server. Maybe if there's an exception coming from a generated assembly, the web server will re-compile it. And the recompiled assembly is fine, because it was created with true .Net 4.0.
Well the answer turned out to be borderline embarrassing. After we confirmed from detailed MSBuild output that it was in fact building the website project against the right reference assemblies, we realized that there are several in-house NuGet packages in the project that had been built against .Net 4.5. One of them was chock full of extension methods, which is what causes the exception. Rebuilding them against .Net 4.0 fixed the problem.
Which brings up an interesting issue. If a 3rd-party NuGet package is compiled for 4.0 but using 4.5 references, we'd be in the same situation, but not able to fix it. So the lesson for package publishers is to ensure your 4.0 version is compiled against the reference assemblies.

Missing GAC with .NET Framework 4 Installation

I've installed the full version of .NET Framework 4 (Client Profile + Extended) on a customer machine which is running Windows Small Business Server 2003 Standard Edition. The installation was successful without any errors. There were no errors mentioned in the log files either...
BUT the .NET Framework 4 GAC (Global Assembly Cache) is completely missing! In other words, the following folder is missing:-
C:\Windows\Microsoft.NET\assembly
If I look into the C:\Windows\Microsoft.NET folder, I can only see 2 subfolders (as shown below) and nothing else.
authman
Framework
The server still has .NET Framework 3.5 installed and is running properly. This means that the GAC folder below exists and has all .NET library DLLs in it. But of course, there are no .NET 4 DLLs in there.
C:\Windows\assembly
Because of the missing .NET Framework 4 GAC, none of my applications run. They all complain about missing System or System.Xml references. If I copy the missing files from the C:\Windows\Microsoft.NET\Framework\v4.0.30319 folder to my application directory, they will stop complaining about these files and start complaining about other missing .NET files. Obviously I use a lot of .NET Library references, and I don't want to copy the whole .NET Framework folder into each of my applications.
Does anyone know how to create the missing GAC? Or at least find out what causes the GAC to disappear? I tried multiple times to re-install the .NET Framework 4, but the GAC is always missing...
Edit: I've also tried running gacutil.exe -l to see what is in the GAC, it only list out .NET assemblies of version 1.0 to 3.5. All .NET 4 assemblies are missing.
Note: .NET 4 version of gacutil.exe only comes with Visual Studio (or Windows SDK), so I have to copy the file to the customer site.