Signed assembly not being recognised - asp.net

I've converted a Visual Studio 2005 Website Project into a Web Application Project by creating a new web app project then copying in all the files and using the 'Convert to Web Application' option. I've added all the same references from the Website project to the web app project. After that I'm down to 1 error in the compiler and it's due to a referenced project.
Error 8
The type 'CSLA.ReadOnlyCollectionBase' is defined in an assembly
that is not referenced. You must add a reference to assembly 'CSLA, Version=1.3.1.0,
Culture=neutral, PublicKeyToken=1ebd9544eb4fe327'. C:\Development\WebApp\WebUI
\Page1.aspx.cs 154 24 WebApp
I've checked and there is a reference to the project and it has a class file for ReadOnlyCollectionBase. The DLL is signed, could this have something to do with it? Also I've copied the web.config directly from the website project into the web app project.
Any help appreciated.

I wouldn't think that this would be a bug with authentication. It is a old version of CSLA though. I would make sure that the CSLA assembly is added as a reference to the web application and exists in the bin directory (Set the Copy Local property on the reference).
Thanks
-Blake Niemyjski (Author of the CodeSmith CSLA Templates)

This just means that you are referencing a dll which uses CSLA and so you need to add a reference to CSLA on that project. This is probably your web project.

Related

Unable to load DLLs when starting up IIS Express hosted web project (VS2015)

Backgroud:
I am in the process of migrating a console application to be part of our existing web API project. All development work is done on Visual Studiod 2015 (with IIS Express). The application uses few third party datasource api DLLs to grab data from that datasource. All these DLLs are managed by our internal nuget package sources.
Issue:
Now the console application runs fine and can load up the those DLLs. I copied across the logic into my web project and added the DLLs via nuget. Solution builds but got the following error when starting up the web project:
Could not load file or assembly 'ABC.DLL' or one of its dependencies. The specified module could not be found.
Where ABC.DLL is one of the third party DLLs.
I have done the following:
Confirm ABC.DLL is in the bin folder of my web project
Changed target build platform of my web project to be x86 and unchecked "Use 64 bit version of IIS Express for websites and project" setting in VS2015 (the third party dll is 32-bit)
Ran dumpbin.exe on ABC.DLL's dependency and got XYZ.dll,MSVCR120.dll,KERNEL32.dll,MSVCP120.dll,mscoree.dll
Regarding to the last step, those dlls were all missing in the bin folder (but the last 4 DLLs should be in system32 win directory so shouldn't matter?)
As for XYZ.dll, it is another third party library and is located on C:\Program Files (x86)\XYZ\ folder. I manually copied it across to the web project bin folder (in fact copied across all Dlls inside XYZ folder) and still get the same issue.
Questions
What am I missing here? The console app obviously can load ABC.DLL but the web project can't. Appreciate it if you can tell me what to check next.
The error message from start up web page is not very useful, is there a way to find out where the web project is trying to load the third party DLLs?
Thank you in advance!
Simply adding external DLLs to your Bin folder is not a great idea. Files can disappear from this folder for various reasons, such as your team members deleting a seemingly useless DLL, or through Visual Studio clearing it. Also, the output DLLs from referenced projects in your solution, would end up there, and are replaced every time you build your project.
What you should do for third-party DLLs, is create some "dependencies" folder in, or close to, your project, and stick the DLLs in there. Then you should right-click on the project, select Add Reference, browse to that new "dependencies" folder, and add a reference to the DLL that way. This is similar to the way NuGet works; it keeps DLLs in their respective folders inside the packages folder, and adds references to those DLLs.
I finally found the issue and thanks for all the help, I had to disable shadow copying in VS (mentioned in 64 bit managed assembly with unmanaged dependencies not loading in IIS / ASP.NET MVC 4).

How to install ASP.NET MVC 5 on a server?

I just updated my website from MVC 4 to MVC 5.
Now when I want to run it on my web server instead of my development machine it does not work.
It think it is because I need to install the MVC 5 libraries on the server but I can't find them.
I downloaded WebMatrix 3 hoping it would provide a way to install it but it only gives me the ability to install MVC 4.
What should I install to be able to run a ASP.NET MVC 5 application?
(without installing Visual Studio 2013)
EDIT:
I disabled custom errors and eror what I have:
Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.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)
EDIT 2:
I found out that the problem was due to one of my dependencies which was using the version 2.0.0.0 of razor.
When you deploy your app just make sure that all the assemblies are being deployed to your production environment in the bin folder. ASP.NET MVC is an xCopy deployment, so you don't have to install anything.
You might want to check that your Production environment has ASP.NET 4.0 and 4.5 registered.
MVC5 and future version of MVC doesn't require to installed on Windows Server. MVC5 app have everything as packages. You didn't need anything to install it.
What is required on server is copy of every library and assembly that you have used in your app. For fix this, Just make sure that everything on your bin folder is called same on server instead of server is looking for it's own GAC for assembly used in your app.
If you didn't found all the packages then you can install nuget packages on server by cmd.
The best is to do a Publish, right click on your project in Solution Explorer and select 'Publish'. Basically it will compile your solution and dump all the assemblies/artifacts to either your webserver, ftp or a local folder.
Make sure all your assembly references are being copied to the deployment directory. To do this you can change the <Reference...> tag in your .project file. Optionally, you can use visual studio's property setter to set the "Copy Local" property of each dll reference to "True".

how does vb.net handle multiple versions of the same dll

I am working on a website written 5 years ago in asp.net 2.0 and vb.net 2005 and visual studio 2005
The website uses a data access layer written using subsonic. The DAL is a class library which imports the subsonic dll. It also needs to import the mysql.data dll to connect to an underlying mysql database. Subsonic needs a specific version of the mysql.data connector (5.2.2) and so this is the version the class library imports.
The website also uses a custom membership provider for mysql. This is another class library which mysql.data dll version 6.5.4
The website uses both the DAL and the custom membership provider and so imports the dlls for both of these class files. I'm confused how it can handle the 2 different versions of the mysql data connector used by these class libraries
The web.config file has this line
<add assembly="MySql.Data, Version=6.5.4.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/></assemblies>
If i delete this line and then rebuild the website the line appears again.
The website also has a copy of the mysql.data 5.2.2 dll in the bin directory. If i delete this file and then rebuild the website the file appears again. In other words the name of the dll appears in the bin directory in the explorer window of visual studio and the physical file appears in the bin directory of the website.
I would really like to know what is going on here and how vb.net can use 2 versions of the same dll. Everything seems to be working ok but the components in this website are so old that they are unsupported. I really don't want to break anything and then not be able to fix it.
Thanks a lot

Compiling ASP.NET project versus NET4.0 with NET4.5 installed

I have an ASP.NET project that was working correctly compiled with Visual Studio 2010 and NET4.0.
Then I have installed VS Express 2012 and NET4.5 and I always get an Exception trying to open a SqlConnection.
Can I have some chance to recompile my project targeting NET4.0 (so without disinstalling 4.5) and have it working?
In VS Express 2012 I have this web.config:
<system.web>
<compilation debug="true" targetFramework="4.0"/>
The referenced assemblies correctly target the v4.0, for example:
Assembly System.Data
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Data.dll
EDIT 2
As this blog http://blogs.msdn.com/b/msbuild/archive/2007/04/12/new-reference-assemblies-location.aspx and also this answer https://stackoverflow.com/a/8543850/1012244 explains very well, there is a BIG difference betweeen Referenced Assemblies (folder contains those assemblies that ship with the x.xx Framework which are useful for referencing during the design and build of new components) and Runtime scenario (At runtime, these components will still be loaded from the GAC in most cases).
However, when I run the project I always get the Exception, as if the project actually was using NET4.5... Why?
PS. If I deploy this project on a production server machine with only NET4.0 installed, the connection is fine.
(This is clear now: Installing Net4.5 essentially replaces Net4.0)
UPDATED QUESTION -
Can I have some chance to recompile my project targeting an OLD NET4.0 .dll (System.Data.dll in my case) instead of the new Net4.5 dll?
EDIT - Additional info
At this MSDN link http://msdn.microsoft.com/en-us/library/ff602939.aspx I found:
If you determine that a change in the .NET Framework 4.5 has broken your application, check the Runtime Settings Schema to determine whether you can use a runtime setting in your application configuration file to restore the previous behavior.
Could this help me? And how?

In Asp.Net 2.0 web site project and Assembly Reference?

Where is the information about the Referenced Assembly kept in an Asp.Net 2.0 Web Site project. Since, there is no .csproj file here we don't know where to look for this. We are facing problems because of multiple version of log4Net being referenced and want to remove one of them.
The only information a website has is the fact that the DLL exists in the bin directory of the website. When you add an external DLL to a project, that DLL is copied into the bin, and a .refresh file is added that provides Visual Studio with the path to the original DLL, so that it can refresh the DLL when it changes.
As far as I know, the assembly tag in web.config is only for GAC assemblies that are added to a project, not external DLLs.
As to your specific problem, if you have class libraries, it is possible that one of those references a different version of the DLL. It is also possible that you have multiple websites and one of them has a .refresh file that is pointing to a different version of the DLL.
In the web.config file under "assembly" tag

Resources