Using Resources

Mikecrosoft
01-15-2004, 09:21 AM
Hi


I have this doubt, how I can use resources in VB.Net (I'm trying to add a image and then use it).

Thanks !

OnErr0r
01-15-2004, 09:45 AM
Add the desired image to your solution. In it's properties under Build Action select Embedded Resouce. Then you can access it with the following code:


Dim asm As System.Reflection.Assembly
asm = System.Reflection.Assembly.GetExecutingAssembly()
Dim str As System.IO.Stream = asm.GetManifestResourceStream("AssemblyName.filename.extension")
bmp = New Bitmap(str)

Mikecrosoft
01-15-2004, 10:16 AM
Thanks, but I dont understand at all:

What is "AssemblyName.Filename.Extension" ??

Sorry I'm new on VB.NET

OnErr0r
01-15-2004, 10:19 AM
In the Solution Explorer window the first icon is the solution name, next is the assembly name. And of course you know your filename and extension.

Mikecrosoft
01-15-2004, 10:21 AM
but the Assemblyname with the .vb extension ?

Mikecrosoft
01-15-2004, 10:32 AM
this is my code in the Form Load Event


Dim asm As System.Reflection.Assembly
Asm = System.Reflection.Assembly.GetExecutingAssembly

Dim str As System.IO.Stream = asm.GetManifestResourceStream("AssemblyInfo.AceptarMask.bmp")

Dim Bmp As New Bitmap(str)


and I attach my solution explorer image

OnErr0r
01-15-2004, 10:34 AM
It's technically the Root Namespace in the GetManifestResourceStream method. But the Assembly Name, Root Namespace and Project Name (second item down in the Solution explorer) are all the same when you create a new project.

OnErr0r
01-15-2004, 10:35 AM
Right click DevProject and look at the Root Namespace, it's likely DevProject too.

Mikecrosoft
01-15-2004, 10:37 AM
so its "DevProject.AceptarMask.bmp", it works !!!

Thanks !!!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum