473,326 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Assembly size C# ./. VB.NET

When I compare a C# and nearly identical VB.NET project, the C# generated
assembly has almost twice the size of the VB assembly. IL code is nearly
identical, but the C# generated assembly contain lots of 00 00 00. What's
that? Or better: How can I stop that?

Jens.

--
http://ManagedXLL.net/ | http://jens-thiel.de/ | http://QuantLib.net/
Replace MSDN with my first name when replying to my email address!
Nov 15 '05 #1
5 4252
Jens,
When I compare a C# and nearly identical VB.NET project, the C# generated
assembly has almost twice the size of the VB assembly. IL code is nearly
identical, but the C# generated assembly contain lots of 00 00 00. What's
that? Or better: How can I stop that?


Which compiler options are you using? Are you looking at release or
debug builds? Strong named or not? Do the assemblies contain any
resources?

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 15 '05 #2
"Mattias Sjögren" <ma********************@mvps.org> wrote
When I compare a C# and nearly identical VB.NET project, the C# generated
assembly has almost twice the size of the VB assembly. IL code is nearly
identical, but the C# generated assembly contain lots of 00 00 00. What's
that? Or better: How can I stop that?


Which compiler options are you using? Are you looking at release or
debug builds? Strong named or not? Do the assemblies contain any
resources?


VS.NET 2003, FrameworkVersion=v1.1.4322
C# class library, default settings, Release build: 16,0 KB (16.384 bytes)
VB.NET class library, default settings, Release build: 5,00 KB (5.120 bytes)

I'm no VB programmer, but the default settings should be similar. No res or
sn.
Oh wait, manifest says .file alignment 512 != 4096.

Bingo, found it. Setting 512 in CS yields: 3,50 KB (3.584 bytes)

Does that have any performance impact?

Jens.

--
http://ManagedXLL.net/ | http://jens-thiel.de/ | http://QuantLib.net/
Replace MSDN with my first name when replying to my email address!
Nov 15 '05 #3

Hi Jens,

Thanks for posting in this group.
Yes, it seems that the default File Alignment settting of C# project is
4096 while VB.net project is 512.
This File Alignment setting will lets you specify the size of sections in
your output file.
The small File Alignment setting will result small file size, because there
will be less padding between the sections.

The article below talks about the technicals you can use to reduce
executable size. But it only talks about VC++, maybe it also helps you, for
your informtion:
http://www.catch22.org.uk/tuts/minexe.asp

Hope this helps,
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #4
""Jeffrey Tan[MSFT]"" <v-*****@online.microsoft.com> wrote
Yes, it seems that the default File Alignment settting of C# project is
4096 while VB.net project is 512.
This File Alignment setting will lets you specify the size of sections in
your output file.
The small File Alignment setting will result small file size, because there will be less padding between the sections.

The article below talks about the technicals you can use to reduce
executable size. But it only talks about VC++, maybe it also helps you, for your informtion:
http://www.catch22.org.uk/tuts/minexe.asp


Jeffrey,

thanks for the link. It is a good summary of native VC++ techniques to
reduce code size. What I really like to know is:

a) Are there any negative effects (on performance, compatibility, startup
time, working set size, ...) when I change the default setting to 512?

b) Why is the default File Alignment settting of C# projects 4096 while for
VB.net project it is 512? Both compiler produce nearly identical IL code!
Jens.

--
http://ManagedXLL.net/ | http://jens-thiel.de/ | http://QuantLib.net/
Replace MSDN with my first name when replying to my email address!
Nov 15 '05 #5

Hi Jens,

Thanks for your feedback.
Actually, the system can use the file alignment value between 512 and 4096,
which have no different performance issue.
So you can reduce the file size through change project's file alignment
setting without performance impact.

For the different choosing of file alignment setting in C# and VB.net, I
think it is by design, it is just .Net development team chooses different
default values.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jeff B. | last post by:
Hello, Can anyone tell me how long an assembly downloaded via a no-touch application will remain in the assembly download cache? I realize I can manually remove them via the "gacutil.exe /cdl"...
0
by: Steve Guidi | last post by:
Hello, I'm developing an application that periodically reads embedded assembly resources. The resources are text-based, and are about 3-7KB in size, and the application accesses them by calling...
25
by: Brian Lindahl | last post by:
I'm using a temporary buffer to transfer some data and would rather not allocate it on the heap. The problem is that the size of the buffer is only known upon entry into the function that utilizes...
1
by: Greg Patrick | last post by:
My problem: I load an some assemblies (strong named) from a byte array using Assembly.Load(byte). They load fine. But one one of them is actually accessed, it's referenced assemblies can't be...
11
by: Wolfgang Kaml | last post by:
I am not sure if this is more of an expert question, but I am sure that they are out there. I'd like to setup a general application or bin directory on my Win2003.Net Server that will hold some...
10
by: ThunderMusic | last post by:
Hi, I need to optimize a close loop. Usually I would use assembly, but I don't event know if it's available to VB.NET. I'll explain the case and maybe some of you will be able to advise me. I...
2
by: rjjaw | last post by:
Here is what I have but it isn't working if someone could point me in the right direction I would greatly appreciate it. Try Dim objAssembly As Reflection.Assembly...
2
by: Peted | last post by:
I have 2 samples of code bellow that work fine at the moment the first routine loads an dll assembley and instantiates the type in the dll which is always a form, and creates a child form from...
1
by: The Great Pawn Hunter | last post by:
Hi everyone, I am a newbie to this group and have a general question. What size assembly is a good size for putting common objects and their methods into so as not to have too much overhead...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.