embedded resources

S

steve

i've created a custom installer that automates some things one of which is
the creation of database tables.

i have put a sql script ("automation.sql") as an embedded resource in the
custom installer project (whose name space is "installer"). here's the code
i'm using to get the script:

private function getEmbeddedText(byval fileName as string) as string
dim assemblyName as string
dim stream as stream
dim text as string
try
assemblyName = [assembly].getexecutingassembly.getname.name.tostring()
stream =
[assembly].getexecutingassembly.getmanifestresourcestream(assemblyName & "."
& fileName)
streamReader = new streamreader(stream)
text = streamReader.readtoend
catch ex as exception
dim message as string = "blah, blah, blah...sorry about that!"
msgbox(message, msgboxstyle.critical)
finally
if text is nothing then text = ""
if not stream is nothing then stream.close()
if not streamReader is nothing then streamReader.close()
end try
return text
end sub

yes, i'm purposely not checking to see if stream is nothing...for now while
debugging. i've tracked the error to this spot as getting the manifest
resource stream "installer.automation.sql" (whilst installing) does not give
me a stream (stream is nothing after the call) and the following line
generates the error.

i thought the reference to embedded resources where the host project's
assembly name...i.e. "installer" and not "Setup" (which is the exe that
kicks everything off. is there an error in the code that i'm overlooking or
do i need to reference the embedded resource differently?

tia,

steve

hey, also...is there a good way to step-through the installer class? i've
just been putting system.diagnostics.debugger.break() as the first line of
code for the base class afterinstall event and then attaching the current
ide to the process when it coughs up errors. surely there's got to be a
better way!

thanks again!
 
S

steve

never mind!

code works fine...it's my typing that sux! "automation.sql" instead of
"automatiion.sql". what a doof! ;^)

lol...cheers,

me

| i've created a custom installer that automates some things one of which is
| the creation of database tables.
|
| i have put a sql script ("automation.sql") as an embedded resource in the
| custom installer project (whose name space is "installer"). here's the
code
| i'm using to get the script:
|
| private function getEmbeddedText(byval fileName as string) as string
| dim assemblyName as string
| dim stream as stream
| dim text as string
| try
| assemblyName = [assembly].getexecutingassembly.getname.name.tostring()
| stream =
| [assembly].getexecutingassembly.getmanifestresourcestream(assemblyName &
"."
| & fileName)
| streamReader = new streamreader(stream)
| text = streamReader.readtoend
| catch ex as exception
| dim message as string = "blah, blah, blah...sorry about that!"
| msgbox(message, msgboxstyle.critical)
| finally
| if text is nothing then text = ""
| if not stream is nothing then stream.close()
| if not streamReader is nothing then streamReader.close()
| end try
| return text
| end sub
|
| yes, i'm purposely not checking to see if stream is nothing...for now
while
| debugging. i've tracked the error to this spot as getting the manifest
| resource stream "installer.automation.sql" (whilst installing) does not
give
| me a stream (stream is nothing after the call) and the following line
| generates the error.
|
| i thought the reference to embedded resources where the host project's
| assembly name...i.e. "installer" and not "Setup" (which is the exe that
| kicks everything off. is there an error in the code that i'm overlooking
or
| do i need to reference the embedded resource differently?
|
| tia,
|
| steve
|
| hey, also...is there a good way to step-through the installer class? i've
| just been putting system.diagnostics.debugger.break() as the first line of
| code for the base class afterinstall event and then attaching the current
| ide to the process when it coughs up errors. surely there's got to be a
| better way!
|
| thanks again!
|
|
 

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