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

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

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 combine vb.net project with vb.net website

I am actually a java/jsp programmer and I am newbie to vb.net. I wonder if I can combine a project made in vb.net 2008 with a vb.net website (like servlet in java)
I have a ready made project with assembly .dll file that is based on 2.0 .net framework.
This project (software) actually to connect it to a handkey 2 hardware. It register users to the handkey.
I want to deploy it to the internet as a website.
-----What I have try so far----
I have created a new website (in vb.net 2008) and add the dll as a reference but it send this error
Could not load file or assembly 'RsiDotNetDLL, Version=2.4.0.3, Culture=neutral, PublicKeyToken=11d948a84312b819' or one of its dependencies. An attempt was made to load a program with an incorrect format.
I just want to share my solution
I have fixed this by open this website with visual studio 2015, select Debug---> Options---> Projects and Solutions---> Web Projects and tick the option "Use the 64 bit version of IIS Express for web sites and projects"
Thanks

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?

Signed assembly not being recognised

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.

Finding the .Net framework

Is there a way to find out which .Net version i.e. 1.1 or 2.0 or 3.0 etc.. was used to create a web project. I have files like .aspx, .aspx.vb, web.config etc but need to figure that out.
Also how to open the existing ASP.Net project in Visual Studio environment. I have received files from another person but for security reasons he do not want to share the complete project but only selected files. We both would like to know what is the bare minimum files which needs to be shared to open an existing project (I mean apart from the .aspx, .aspx.vb files which needs to be modified)
Thanks
If its ASP.NET project check the <assemblies> element in web.config its must contain versions of each assembly you use.
Please try this:
Open Visual Studio.
Click on File -> Open -> WebSite (Or press Alt+Shift+O).
Select the folder which containing your file (aspx, aspx.vb, web.config)
In most of the cases it will open the folder as web site and you can run it with F5.
I don't think the files you mentioned will contain any references to the version of .NET they were build under, not unless they feature version-specific code & functionality (LINQ for 3.0+. generics for 2.0+ etc).
In order to open an actual Web project in Visual Studio, you need the project file. Without that you will only be able to open individual files.

Resources