res:// protocol in VB.NET

C

Charles Law

I have added a GIF to my project and wish to retrieve it using the res://
protocol. As an example, the first string below works, whilst the second
does not.

Const s1 As String = "res://c:\windows\system32\shdoclc.dll/pagerror.gif"
Const s2 As String = "res://c:\test\mycontrol.dll/comments.gif"

If I Ctrl+Click on the first in the IDE then the page is opened. Doing the
same on the second simply displays the default "The Page cannot be
displayed" page.

I have added the GIF to my project using "Add Existing Item ..." and
changing the Build Action to Embedded Resource. I have also tried adding a
RESX file containing the resource. I rebuild the project but neither of
these seems to work.

Can anyone suggest how it should be done?

[The reason I want to use the res:// protocol is to load custom glyphs into
the WebBrowser control, and I want them to be part of the assembly. The Add
Glyph to Table command can take a path name or a res:// protocol descriptor.
The latter seems to be the only way to read them from a resource file. If
there is another way please let me know]

TIA

Charles
 
H

Herfried K. Wagner [MVP]

Hello,

Charles Law said:
Const s1 As String = "res://c:\windows\system32\shdoclc.dll/pagerror.gif"
Const s2 As String = "res://c:\test\mycontrol.dll/comments.gif"

If I Ctrl+Click on the first in the IDE then the page is
opened. Doing the same on the second simply displays
the default "The Page cannot be displayed" page.

I have added the GIF to my project using "Add Existing
Item ..." and changing the Build Action to Embedded
Resource. I have also tried adding a RESX file containing the
resource. I rebuild the project but neither of
these seems to work.

The res-protocol won't work with resx resources, I think. You will have to
use Win32 resources (you must compile using the "vbc" compiler and add the
Win32 resource file by specifying the file in "/win32resource:".
 
C

Charles Law

Hi Herfried

Thanks for the info. I have been looking into this and am still not sure how
to achieve my goal.

Can I do the compile from within the IDE or do I have to resort to the
command line :-( ?
My project has a .vbproj file (and several .vb files), so what would my
command line look like, assuming the project is called MyProj and the
resource file is called MyRes.Res?

Thanks for you help.

Charles
 
H

Herfried K. Wagner [MVP]

Hello,

Charles Law said:
Can I do the compile from within the IDE or do I have to resort to the
command line :-( ?

AFAIK this cannot be done from within the IDE.

:-(
My project has a .vbproj file (and several .vb files), so what would my
command line look like, assuming the project is called MyProj and the
resource file is called MyRes.Res?

Have a look at the documentation for "vbc.exe". You won't be able to use
the project file when compiling from the command line.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top