Page 1 of 2

dll resource file

Posted: Sun May 09, 2010 1:23 pm
by AleRi8
Hi, how do i create a dll to which it holds all the program images so my main program will load the images from a dll to the main application


thanks

Re: dll resource file

Posted: Sun May 09, 2010 5:30 pm
by mandai
You can put the images in as embedded resources for the dll project, then have some code in in your application like this:
Code: Select all
        Dim dll As Assembly = Assembly.GetAssembly(GetType(ClassLibrary1.Class1))
        Dim myResources As String() = dll.GetManifestResourceNames()

        msgbox(myResources(0))
        Dim resStream As Stream = dll.GetManifestResourceStream(myResources(0))
        Dim image1 As Image = Image.FromStream(resStream)
        resStream.Close()

        PictureBox1.Image = image1

Re: dll resource file

Posted: Mon May 10, 2010 3:15 pm
by AleRi8
ok thx i'll give it ago

Re: dll resource file

Posted: Tue Jun 01, 2010 4:36 pm
by AleRi8
i tryed that but it comes up 2 errors with message box with reference.reference + object to refence to object is null

Re: dll resource file

Posted: Tue Jun 01, 2010 5:59 pm
by mandai
You have to have at least 1 image file as an embedded resource in your project for it to work.

Re: dll resource file

Posted: Sat Jun 05, 2010 2:56 pm
by AleRi8
lol i did add a image file i have uploaded the main app and dll source files in first post

Re: dll resource file

Posted: Sat Jun 05, 2010 9:20 pm
by mandai
Looks like you forgot to set the build action to embedded resource for your Image1.bmp/xddd.png files in the dll project.

Re: dll resource file

Posted: Mon Jun 07, 2010 5:11 pm
by AleRi8
lol ok thanks for your time i dont know much about dlls :)

Re: dll resource file

Posted: Tue Jun 08, 2010 2:40 pm
by AleRi8
i tryed it again last night and recompiled to what you z and i had added a referance to the file but now the name classlibary1.clase highlights blue but when i recompile it as a compiler then the blue line disapears

Re: dll resource file

Posted: Tue Jun 08, 2010 4:47 pm
by mandai
Maybe you called the class library something different?