I have a assembly made in another project (projA). Now I want to import this dll in another project (projB). How can I achieve this? This is what I've tried (in projB).
1 Put dll in same dir as my project. (the bin dir)
2 In web.config:
<assemblies>
<add assembly="projA, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
This is the error I get:
Could not load file or assembly 'projA, 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)
EDIT:
The point is that eventually the assembly reference must me added dynamically
EDIT 2:
The name of the assembly (and namespace) are stored in the database. The physical assembly (dll) is added (by installation) in projB. Now the code in projB must read the assembly name from the database and then add a reference to the dll which is added by installation.
An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. Assemblies take the form of executable (.exe) or dynamic link library (. dll) files, and are the building blocks of . NET applications.
The MVC framework is defined through System. Web. Mvc assembly. This is because this is the only assembly which contains classes and interfaces that support the ASP.NET Model View Controller (MVC) framework for creating Web application.
Yes you can have two web. config files in application.
Are all of projA's dependencies in projB? Usually I'd just add a reference from one project to another if they are in the same solution.
Edit:
If you want to add an assembly dynamically then maybe a service reference maybe something to consider. By dumping in projA's DLL into the bin that doesn't really give all the DLLs that it may require, thus there are ways to tie things together so that objects can be understood across systems, like web services using XML to give a common example.
My question back about adding an assembly dynamically is where would you get it from and can that part be automated to be part of projB as that is really the general solution to this kind of problem.
Edit 2:
How could you get all of projA's dependencies? Is it possible to get it so that it doesn't depend on a bunch of other DLLs that may or may not be on the system that this is to run. That is what the error is telling you, that there exists some assembly projC that is also required. Note that this adding of assemblies can continue for a long time if there are many levels of dependencies used.
Summarizing the answer: What would you need to reference in order to load projA into some new project? That's your problem which without knowing what the dependencies look like is rather hard to answer directly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With