Guest Posted March 13, 2009 Share Posted March 13, 2009 I am building a tookit system that can take plugins... The main toolkit can get the plugin name from one of the classes no problem but how do i actually access images stored in the dll. .DLL files are not extracted anywhere during execution are they? Just wondering how i would access a .jpg image from a .dll file... Would i have to use reflection? Link to comment Share on other sites More sharing options...
0 Doli Posted March 13, 2009 Share Posted March 13, 2009 If the image is added to the Resource section in the .dll then you can call it with Properties.Resources.IMAGE_NAME in the when making the .dll. You can make this resource public from the resource view in "Access Modifier" so your program can get the image with DLL_NAME_SPACE.Properties.Resources.IMAGE_NAME or have the .dll have a method that returns the image by following rules that are specified from using an Interface. Thats my guess. Link to comment Share on other sites More sharing options...
0 Guest Posted March 13, 2009 Share Posted March 13, 2009 Dead on... Thanks a million.... :D Link to comment Share on other sites More sharing options...
0 Guest Posted March 14, 2009 Share Posted March 14, 2009 Dont want to start a new topic but i seem to be having a lot of trouble with .dll files... Cant wrap my head around them. I got the images working but now im having a problem with the WPF MediaPlayer... I cant seem to load the song... Tried putting the music clips in a resource file like the images but cant seem to access them as its asking for a URI. Here are the two things i tried... no luck musicPlayer.Open(new Uri("gomen.mp3", UriKind.Relative)); musicPlayer.Open(new Uri(Sound.Resources.gomen.ToString())); Dont understand why the first example wont work... Link to comment Share on other sites More sharing options...
0 Guest Posted March 14, 2009 Share Posted March 14, 2009 Anyone? Cant be too difficult... :p Link to comment Share on other sites More sharing options...
0 Guest Posted March 14, 2009 Share Posted March 14, 2009 Apparently MediaPlayer, SoundPlayer and MediaElement cant play from resource files... Needed to move the sound clips from the resource to disk using the following method. private void moveResourcesToDisk(String resource_Name) { Directory.CreateDirectory(Settings.workingDirectory + @"\Sound Files\"); MemoryStream inStream = new MemoryStream((byte[])Sound.Resources.ResourceManager.GetObject(resource_Name)); MemoryStream storeStream = new MemoryStream(); storeStream.SetLength(inStream.Length); inStream.Read(storeStream.GetBuffer(), 0, (int)inStream.Length); storeStream.Flush(); inStream.Close(); // create the temporary file... if (File.Exists(Settings.workingDirectory + @"\Sound Files\" + resource_Name + ".mp3") == false) { FileStream outStream = File.OpenWrite(Settings.workingDirectory + @"\Sound Files\" + resource_Name + ".mp3"); storeStream.WriteTo(outStream); outStream.Flush(); outStream.Close(); } storeStream.Close(); } Link to comment Share on other sites More sharing options...
Question
Guest
I am building a tookit system that can take plugins...
The main toolkit can get the plugin name from one of the classes no problem but how do i actually access images stored in the dll.
.DLL files are not extracted anywhere during execution are they?
Just wondering how i would access a .jpg image from a .dll file...
Would i have to use reflection?
Link to comment
Share on other sites
5 answers to this question
Recommended Posts