468,291 Members | 1,427 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,291 developers. It's quick & easy.

resources.GetObject("imageList1.ImageStream") throws System.Reflection.TargetInvocationException

Hi,

I was in trouble with the System.Windows.Forms.ImageList control from
VC.NET. I was doing the following :

1. New Project, C#, Windows Application
2. Add ImageList component imageList1 to Form1
3. in imageList1 properties open the 'Image Collection Editor' for
Images
and add a simple copy.bmp
4. build and run the application

What I get here is an TargetInvocationException at this line
this.imageList1.ImageStream =
((System.Windows.Forms.ImageListStreamer)(resource s.GetObject("imageList1.Im
ageStream")));

I finally found a solution for that and I just want to post it for
others who may encounter this problem.

VC.NET is using an application manifest to enable visual styles within
the IDE with "devenv.exe". I don't know why but the problem cames from
that manifest file. To fix the problem, create a manifest file and name
it yourappname.exe.manifest

Paste this code into that file:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1"
manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="X86"
name="WindowsXP"
type="win32"
/>
<description>Your application description here.</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>

Now, use this file for any application you want to use XP styles for,
including VS.NET. You can put this manifest file in the .NET app
folder. Run VS.NET and you'll see xp styles. Make sure "flatstyle" for
your buttons and frames is set to "system".

Nov 17 '05 #1
0 7649

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by groovyjman21 | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by Teichintx | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.