473,405 Members | 2,310 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,405 software developers and data experts.

.NET dynamic assembly with a custom icon?

15
I've been recently working on application that generates .net assemblies on-the-fly using the methods in System.Reflection.Emit. It works well, but i would like to also change the icon of my freshly baked exe, so it would not appear the default icon.
The idea is to be able to embed the icon in the assembly, (i guess as a resource) and make that icon a default assembly icon. I am not talking about window icon that can be set on any window, but the icon of the executable.

Thanks in advance
Oct 2 '08 #1
4 2417
joedeene
583 512MB
maybe this will help you, a simple search on google.com is always useful...

Link 1

joedeene
Oct 2 '08 #2
l034n
15
Thanks for the reply joedeene. Well, i did search on google for hours before i posted it here with no luck. The problem is that i need this done with System.Reflection.Emit, so it should be dynamic assembly generation on-the-fly with AssemblyBuilder. I know very well how to embed resources in the current assembly (or in it's res/resource file). The trouble comes when i want to make some of those embedded icons to be the actual exe icon once it's generated using the AssemblyBuilder (pardon the redundancy).
I have tried embedding icons in VS and setting one of them as assembly icon (which always works doing it with VS IDE), so then I checked the generated assembly using ildasm, but i just can't seem to find the connection between the icon and the assembly (where the icon is actually assigned to the assembly). Of course, i see the icon in the Resources, but i don't see any piece of code where it actually is referenced, hence i asked if anyone has any idea of how that can be done.
Oct 2 '08 #3
Plater
7,872 Expert 4TB
I too attempted to search where it keeps track of what icon to use for an assembly and could not find it. I don't think it's assigned until the "linker" stage when the exe is produced? It seems to be in the project file itself.

So here is what I found for differences:
Expand|Select|Wrap|Line Numbers
  1. //Using an icon in the resx resource file
  2. <PropertyGroup>
  3.   ...
  4.   <Win32Resource>
  5.   </Win32Resource>
  6.   <ApplicationIcon>Resources\testicon.ico</ApplicationIcon>
  7. </PropertyGroup>
  8.  
  9. <Compile Include="Properties\Resources.Designer.cs">
  10.   <AutoGen>True</AutoGen>
  11.   <DependentUpon>Resources.resx</DependentUpon>
  12.   <DesignTime>True</DesignTime>
  13. </Compile>
  14.  
  15. <ItemGroup>
  16.   <Content Include="MCI_ERROR.txt" />
  17.   <None Include="Resources\testicon.ico" />
  18. </ItemGroup>
  19.  
Expand|Select|Wrap|Line Numbers
  1. //using win32resource res file
  2. <PropertyGroup>
  3.   ...
  4.   <Win32Resource>C:\Projects\testsolution\testproject\ResTempl1.res</Win32Resource>
  5. </PropertyGroup>
  6.  
  7. <Compile Include="Properties\Resources.Designer.cs">
  8.   <AutoGen>True</AutoGen>
  9.   <DependentUpon>Resources.resx</DependentUpon>
  10. </Compile>
  11.  
  12. <ItemGroup>
  13.   <Content Include="MCI_ERROR.txt" />
  14. </ItemGroup>
  15.  
Maybe something there will help you?
Oct 3 '08 #4
l034n
15
Thanks for the pointer Plater. That is some progress in the right direction. Although i still can't seem to put all the pieces together, it was helpfull. I just wonder if i am going to solve this the way i am doing it (making assembly with Emit) and if it's even possible. There is a switch in csc.exe (/win32icon:<file>) which can be used to assign an icon, but then the whole point of using Emit is to make the assembly dynamically, not to redistribute c# compiler along with the program that generates dynamic assemblies, and then dump a source file and call the compiler (which as a last resort can be done, but i wouldn't go for it... yet). Then, i check ilasm switches and i don't see anything like that, and it comes clear that using ilasm.exe the icon can not be set either. So, it must be possible to set it somehow with IL, or the tools aren't mature enough yet.
I wouldn't like to think that the guys in M$ code the Emit namespace (which is really a great one) but made it in a way that every assembly generated this way will have the default icon. It just doesn't make sense.
I'll keep digging into this and if i find a solution, i'll post it here... until than maybe someone will give me a hand :-)
Oct 3 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Stephen Gennard | last post by:
Hello, I having a problem dynamically invoking a static method that takes a reference to a SByte*. If I do it directly it works just fine. Anyone any ideas why? I have include a example...
0
by: Eric Marthinsen | last post by:
Hello- I'm working on a system that manages manufacturer data. From time to time, we send information to a manufacturer. The method can vary widely. What I'm attempting is to add two fields to...
6
by: Philipp Schumann | last post by:
Hi, I have a need for "dynamic type casting": in other words, in a "MyConvert" method I get passed an Object "value" and a Type "type" and the method should attempt to convert value into type. ...
3
by: Michael Bøcker-Larsen | last post by:
Hi I'v been stuck on this problem for ages now. I have found that I'm not the only one with this problem, by looking through the different newsgroups. Hope you can help me! I know there is a...
2
by: Dexter | last post by:
Hello all, I build a Custom Web Control and now, i want to include a icon in my assembly. How i make this? Thanks Dexter
8
by: Umut Tezduyar | last post by:
I know that, in asp.net 2.0, the assembly for the web site is splitted into pieces and each time you build it, it generates a random name for assembly. My question is, if i create a custom web...
0
by: BrianKer | last post by:
Hi! It's my first discussion on this forum. First I have a exe like this below (the object can invoke by console) public class DynamicLoad { public Type AssemblyType = null; ...
0
by: pso19 | last post by:
Hi, I am trying to access all the properties, methods of an assembly using reflection. But what i want to do is invoke a method which contains custom parametrs like enumeration defined in a...
15
by: EDBrian | last post by:
My problem is this. Our clients create different fields they want to collect and we allow them build dynamic filters, reports etc... We run some TSQL to actually create the column and all works...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.