6

From Can I build 2 or more dlls from C# project in Visual Studio 2008?, I have another idea to create only 1 big project. After that, I separate a project dll(that contains many classes.) into 1 dll per class by using post-build event to call Win app project(for separate a big dll). How to do this?

Moreover, I need to manage attached file in a big dll too.

Update I found some trick that could guide me to solve this problem by custom build? Moreover, I think I can create custom handler that generate dynamic assembly file by using separate module file & al.exe. But this feature is over my expect and unnessary(sourcecode is rarely changed).

Multi-file Assemblies: What and How

How to: Build a Multifile Assembly

POCO Custom Multifile Assembly and ReSharper

Thanks,

Community
  • 1
  • 1
  • 6
    Why would you want to do this? – Fredrik Mörk Apr 29 '09 at 07:27
  • I think you would get better answers if you highlight that this is for the purposes of Silverlight controls... – Marc Gravell Apr 29 '09 at 07:43
  • If you have big website that use silverlight to display, you will spend long time to load home page. –  Apr 29 '09 at 07:48
  • Then maybe the real answer is that you shouldn't use Silverlight for what you're doing? – Jon Limjap Apr 29 '09 at 08:10
  • JavaFX? I don't like Java and I work as .Net Developer. Moreover, I like Silverlight(.net strongly type + vs.net + RIA) because I hate javascript. –  Apr 29 '09 at 08:46
  • I think you would do better by taking 1 step back and describing what you're trying to accomplish. You may get some better methods for accomplishing the same thing. – Rex M Apr 29 '09 at 17:59
  • 1
    There is an answer already in this site, please take a look at the [following solution](http://stackoverflow.com/questions/3867113/visual-studio-one-project-with-several-dlls-as-output) – franko_camron Dec 06 '11 at 19:41

3 Answers3

8

Just... why? Having lots of dlls can have a performance impact on app startup (due to "fusion"). It will also pretty-much immediately suffer from circular references, which is a bad thing.

Since .NET code (by default) gets JITted when first used, there isn't a huge amount of impact in having extra classes in a dll that don't get used in that application. They just sit there, quietly, being no bother to anyone.

The sheer management cost of having a dll per class will make deployment etc excruciating.

All in all, I can't think of a sensible reason to do this...

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
  • Because I want to create Silverlight application like webform(1 Silverlight usercontrol equals 1 webpage). So, I need to create 1 dll for 1 Silverlight usercontrol. –  Apr 29 '09 at 07:39
  • I occasionally separate out large classes like the DAL to shorten build time of the BLL classes. But to do that for each class, you are right; no "sensible reason". – missaghi Apr 29 '09 at 18:07
  • It's true. For all in one place application, this idea is unnessary. But for server/client application, this idea is great, if it can be true(creating silverlight page almost equal creating web page). –  Apr 29 '09 at 18:59
7

The answer that you will get here is no different from the answer in the other question: put in a separate project for each separate dll.

What I want to ask you is what your understanding of the definition of a "class" is. One class per DLL probably means that you're not very familiar with how assemblies, namespaces, and classes work.

Tell us, what do you really want to be able to do? Because what you think you should be doing to solve that problem (e.g., creating one DLL per class) is not practical.

Update

Considering the context of your requirement (e.g., Silverlight web application), my conclusion is that splitting your classes to several DLLs will not result in a performance improvement in an ASP.NET web page because:

  • DLLs are only used by the server, they are not downloaded via HTTP to your browser
  • Once a DLL is loaded by a web application it won't load it again -- regardless of how many users are using your site at the same time. One DLL instance per server.
  • When you start your web application it will load all DLLs that it depended on to compile, whether or not you will use it.

So with your requirements, it's probably best NOT to use Silverlight for your application, considering the bandwidth limit. The avenues you can explore are:

  • Learning AJAX techniques, specifically JSON, (and probably not ASP.NET AJAX and its easy-to-misuse UpdatePanel)
  • Learning jQuery to find controls that will implement in JavaScript what you want to do using Silverlight
Community
  • 1
  • 1
Jon Limjap
  • 94,284
  • 15
  • 101
  • 152
  • you might want to add a link to the related question – Gad Apr 29 '09 at 07:29
  • 2
    In other words "You keep asking this question. I do not think it means what you think it means!" :) – JP Alioto Apr 29 '09 at 07:30
  • From my old question, I can create a lot of project for solve this problem. But, It hard to manage a lot of project(100+) in 1 solution. –  Apr 29 '09 at 07:50
  • But WHY do you need 1 class per DLL in the first place? – Jon Limjap Apr 29 '09 at 08:09
  • Because startup page can load all of page partially that user want to view. I think, It's the only one idea to match between first loading time and smart RIA. –  Apr 29 '09 at 09:46
  • Please answer my question. I learned AJAX several year ago(my app such as ragnarok-like chatroom). Today, I want to use Silverlight instead of web application(Asp.net MVC + jQuery). The following features are javascript based application can't give me. - Managed code that server & client can share piece of code(like .Net RIA Service). - Strongly type. - Building rich UI cross browser(when I use CSS-based app, I open at least 3 browsers to test it). - Drawing nice vector object. - Great UX. Thank a again for interesting my easy question –  Apr 29 '09 at 11:34
  • @JonLimjap : I have a test project and suppose having 50 Test Classes, So I want to make separate DLL based on same Alphabetical name or those having same namespace. It make me easy to run those test dll in Test Suits separately and it each test case will finish in less time. So kindly let me know how to achieve it if know ? – Ajay Sharma Oct 27 '17 at 10:16
3

This problem is solved by custom script for MSBuild that was explained in another question.

<ItemGroup> 
  <Compile Include="Class1.cs"> 
    <Plugin>true</Plugin> 
  </Compile> 
  <Compile Include="Class2.cs" /> 
  <Compile Include="Class3.cs"> 
    <Plugin>true</Plugin> 
  </Compile> 
  <Compile Include="Program.cs" /> 
  <Compile Include="Properties\AssemblyInfo.cs" /> 
</ItemGroup> 

Visual studio one project with several dlls as output?

Thanks @franko_camron for suggestion.

user229044
  • 232,980
  • 40
  • 330
  • 338