Lunchtime Longhouse

getcher turnip onna stick

Previous Entry Add to Memories Tell a Friend Next Entry
today on “find the bug”
jazz
[info]jeffpaulsen

work post – if you’re one of those folks that reads my blog for the pictures, just move along :)

I’ve got some code that compiles .resx files at run time, using them to make an in-memory resource dll assembly that I can use from a ResourceManager object. I take the RESX and convert it to a .resources file in the temp dir (which I get from Path.GetTempPath()), whose name is in a string var named resFileName.

There’s a bug in this code:

   1:    Dim vbCompiler As VBCodeProvider = New VBCodeProvider()
   2:    Dim codeParams As CompilerParameters = New CompilerParameters()
   3:  
   4:    codeParams.GenerateExecutable = False
   5:    codeParams.GenerateInMemory = True
   6:    codeParams.CompilerOptions = "/nostdlib /noconfig  /define:_MYTYPE=\""Empty\""  /resource:" & resFileName & "


If resFileName is a path containing spaces, our compile won’t go. On some systems, the temp path will contain spaces.

Here's how we get rid of it (see lines 6 & 7):

   1:    Dim vbCompiler As VBCodeProvider = New VBCodeProvider()
   2:    Dim codeParams As CompilerParameters = New CompilerParameters()
   3:  
   4:    codeParams.GenerateExecutable = False
   5:    codeParams.GenerateInMemory = True
   6:    codeParams.CompilerOptions = "/nostdlib /noconfig  /define:_MYTYPE=\""Empty\"""
   7:    codeParams.EmbeddedResources.Add(resFileName)

Simple once you know how. The moral of the story is never concatenate a filename into a string if you don’t have to.


*blinks* I will remember that, despite being interested in peoples work lives, I need a translator for yours =D

computer people are like rock stars as far as I'm concerned!


Home