RobertBurdickeMVP
Tue Oct 11 11:55:30 CDT 2005
Yep!! Another sure sign of this is if you look at the properties of any
assemblies that your own DLL references, and they point to the big Windows
.NET framework versions vs. the compact framework versions, you'll have this
kind of problem.
Robert
"Robert W." wrote:
> Robert,
>
> Thank you for your feedback. You know what my ultimate problem turned out
> to be? I [stupidly] didn't know that there was such a thing as a "Smart
> Device Class Library". I had seen people refer to this but just assumed it
> meant "a class library that is reference by a CF project".
>
> So what I had inadvertently done is create a WinForms class library project
> (called "Multimedia" in my case) and add embedded images and a class file of
> assorted methods to it. This worked fine with my WinForms app but kept on
> failing with my CF app. I just couldn't understand why. Especially when I'd
> copy the same code into my CF project and it worked fine!
>
> Only today did I learn what I had done wrong. And voila, after creating a
> Smart Device Class Library and copying everything back into it, I discovered
> that my original code worked fine! In both my CF app and my WinForms app no
> less!!!
>
> The following probably won't benefit you but maybe it'll save someone else
> some time. These two GetImage methods reside inside my Multimedia class
> library. They're designed to allow the retrieval of a single image (ie. once
> and never again) or an image that is part of an animation.
>
> One great part about it is that in the calling code I don't need to worry
> about how many frames there are in the animation. For because I'm passing to
> the [2nd] GetImage an integer parameter By Reference, it automatically resets
> it back to 1 after it reaches the highest number in the sequence.
>
>
> public static Image GetImage(string imageName)
> {
> int imageNum = -1;
> return GetImage(imageName, ref imageNum);
> }
>
> public static Image GetImage(string imageBaseName, ref int imageNum)
> {
> string fullName = "";
> Bitmap image = null;
> Stream stream;
>
> Assembly assembly = Assembly.GetExecutingAssembly();
>
> string assemblyName = assembly.GetName().ToString();
> assemblyName = assemblyName.Substring(0, assemblyName.IndexOf(","));
> // ie. "Multimedia"
>
> // Is this just a single (ie. one-time) image?
> if (imageNum == -1)
> {
> fullName = assemblyName + "." + imageBaseName + ".jpg";
> stream = assembly.GetManifestResourceStream(fullName);
> }
> else // Or is it one of many in an animation
> {
> fullName = assemblyName + "." + imageBaseName + imageNum.ToString()
> + ".jpg";
> stream = assembly.GetManifestResourceStream(fullName);
>
> if (stream == null)
> {
> imageNum = 1; // Reset sequence
> fullName = assemblyName + "." + imageBaseName + "1.jpg";
> stream = assembly.GetManifestResourceStream(fullName);
> }
> }
>
> if (stream != null)
> image = new Bitmap(stream);
>
> stream.Close();
>
> return image;
> }
>
>
> --
> Robert W.
> Vancouver, BC
> www.mwtech.com
>
>
>
> "Robert Burdick [eMVP]" wrote:
>
> > You need to make sure that the name of the resource you are interested in
> > loading is correct. Embedded resources like bitmaps follow the following
> > naming convention:
> > Namespace.Filename
> >
> > So a bitmap named myBitmap.map in an assemby with nampace foo would be
> > loaded as foo.myBitmap.bmp. Try passing this to your GetImage method and see
> > if it works. You can also prepend the namespace name in the method if you
> > don't want your client applications to have DLL specific namespace names in
> > them.
> >
> > Look here for more details:
> >
> >
http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=75
>